Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

adds forgot password page

Alaister Youngc81a72f666d3
diff --git a/studio/components/interfaces/Login/ForgotPasswordForm.tsx b/studio/components/interfaces/Login/ForgotPasswordForm.tsx
index becbd6b0f6a..272cdb60671 100644
--- a/studio/components/interfaces/Login/ForgotPasswordForm.tsx
+++ b/studio/components/interfaces/Login/ForgotPasswordForm.tsx
@@ -1,5 +1,53 @@
+import { auth } from 'lib/gotrue'
+import { Button, Form, Input } from 'ui'
+import { object, string } from 'yup'
+
+const forgotPasswordSchema = object({
+ email: string().email('Must be a valid email').required('Email is required'),
+})
+
const ForgotPasswordForm = () => {
- return <div></div>
+ const onForgotPassword = async ({ email }: { email: string }) => {
+ const result = await auth.resetPasswordForEmail(email)
+ console.log('result:', result)
+ }
+
+ return (
+ <Form
+ validateOnBlur
+ id="forgot-password-form"
+ initialValues={{ email: '', password: '' }}
+ validationSchema={forgotPasswordSchema}
+ onSubmit={onForgotPassword}
+ >
+ {({ isSubmitting }: { isSubmitting: boolean }) => {
+ return (
+ <div className="mb-4 space-y-4 pt-4">
+ <Input
+ id="email"
+ name="email"
+ type="email"
+ label="Email"
+ placeholder="[email protected]"
+ />
+
+ <div className="border-overlay-border border-t" />
+
+ <Button
+ block
+ form="forgot-password-form"
+ htmlType="submit"
+ size="medium"
+ disabled={isSubmitting}
+ loading={isSubmitting}
+ >
+ Send Reset Email
+ </Button>
+ </div>
+ )
+ }}
+ </Form>
+ )
}
export default ForgotPasswordForm
diff --git a/studio/components/interfaces/Login/LoginForm.tsx b/studio/components/interfaces/Login/LoginForm.tsx
index c0af5e994d9..39dcbd416bd 100644
--- a/studio/components/interfaces/Login/LoginForm.tsx
+++ b/studio/components/interfaces/Login/LoginForm.tsx
@@ -1,5 +1,4 @@
import { auth } from 'lib/gotrue'
-import Link from 'next/link'
import { Button, Form, Input } from 'ui'
import { object, string } from 'yup'
@@ -15,56 +14,48 @@ const LoginForm = () => {
}
return (
- <div>
- <h1>Login</h1>
-
- <Form
- validateOnBlur
- id="login-form"
- initialValues={{ email: '', password: '' }}
- validationSchema={loginSchema}
- onSubmit={onLogin}
- >
- {({ isSubmitting }: { isSubmitting: boolean }) => {
- return (
- <div className="mb-4 space-y-4 pt-4">
- <Input
- id="email"
- name="email"
- type="email"
- label="Email"
- placeholder="[email protected]"
- />
-
- <Input
- id="password"
- name="password"
- type="password"
- label="Password"
- placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;"
- />
-
- <div className="border-overlay-border border-t" />
-
- <Button
- block
- form="login-form"
- htmlType="submit"
- size="medium"
- disabled={isSubmitting}
- loading={isSubmitting}
- >
- Login
- </Button>
- </div>
- )
- }}
- </Form>
-
- <Link href="/forgot-password">
- <a>Forgot Password</a>
- </Link>
- </div>
+ <Form
+ validateOnBlur
+ id="login-form"
+ initialValues={{ email: '', password: '' }}
+ validationSchema={loginSchema}
+ onSubmit={onLogin}
+ >
+ {({ isSubmitting }: { isSubmitting: boolean }) => {
+ return (
+ <div className="mb-4 space-y-4 pt-4">
+ <Input
+ id="email"
+ name="email"
+ type="email"
+ label="Email"
+ placeholder="[email protected]"
+ />
+
+ <Input
+ id="password"
+ name="password"
+ type="password"
+ label="Password"
+ placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;"
+ />
+
+ <div className="border-overlay-border border-t" />
+
+ <Button
+ block
+ form="login-form"
+ htmlType="submit"
+ size="medium"
+ disabled={isSubmitting}
+ loading={isSubmitting}
+ >
+ Login
+ </Button>
+ </div>
+ )
+ }}
+ </Form>
)
}
diff --git a/studio/pages/forgot-password.tsx b/studio/pages/forgot-password.tsx
index 2be3114a874..ff5f6bbeed5 100644
--- a/studio/pages/forgot-password.tsx
+++ b/studio/pages/forgot-password.tsx
@@ -1,5 +1,31 @@
-const ForgotPasswordPage = () => {
- return <div></div>
+import ForgotPasswordForm from 'components/interfaces/Login/ForgotPasswordForm'
+import { LoginLayout } from 'components/layouts'
+import Link from 'next/link'
+import { NextPageWithLayout } from 'types'
+
+const ForgotPasswordPage: NextPageWithLayout = () => {
+ return (
+ <>
+ <div className="flex flex-col gap-4">
+ <ForgotPasswordForm />
+ </div>
+
+ <div className="w-full border-t border-scale-700 my-4" />
+
+ <div className="mb-4">
+ <span className="text-scale-1000">Already have an account?</span>{' '}
+ <Link href="/">
+ <a className="underline hover:text-scale-1100">Login</a>
+ </Link>
+ </div>
+ </>
+ )
}
+ForgotPasswordPage.getLayout = (page) => (
+ <LoginLayout title="Forgot Password" showDisclaimer={false}>
+ {page}
+ </LoginLayout>
+)
+
export default ForgotPasswordPage