Skip to content

Commit

Permalink
feat(auth): send password reset email on submit
Browse files Browse the repository at this point in the history
  • Loading branch information
natashatikhonova committed Aug 29, 2023
1 parent 0d2baf7 commit 8bd4b2c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions next-tavla/src/Admin/scenarios/Login/components/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ import { SyntheticEvent } from 'react'
import { FirebaseError } from 'firebase/app'

function ResetPassword({ popPage }: { popPage: () => void }) {
const { error, setError, getTextFieldPropsForType } = useFirebaseAuthError()
const auth = getAuth()

const submitResetPassword = async (event: SyntheticEvent) => {
event.preventDefault()

const data = event.currentTarget as unknown as {
email: HTMLInputElement
}

const email = data.email.value

try {
await sendPasswordResetEmail(auth, email)
popPage()
} catch (error: unknown) {
if (error instanceof FirebaseError) {
setError(error)
}
}
}

return (
<div>
<Image src={musk} alt="illustration" className="h-50 w-50" />
Expand Down

0 comments on commit 8bd4b2c

Please sign in to comment.