feat: implement email verification flow and enhance user experience
- Added EmailVerificationBanner component to notify users about unverified email status and provide a resend verification option. - Introduced VerifyPage for handling email verification via a token in the URL, including success and error handling. - Updated LoginPage and AccountSettingsPage to allow users to resend verification emails directly from these pages. - Enhanced API utility with new functions for verifying emails and resending verification requests. - Updated routing to include the new verification page and improved link structure for verification links.
This commit is contained in:
1 parent
c6569abe1a
commit
2646bc776a
10 files changed
+390
-17
No files matched your search
@@ -13,6 +13,7 @@ function AccountSettingsPage() {
|
||||
const [newPw1, setNewPw1] = useState('')
|
||||
const [newPw2, setNewPw2] = useState('')
|
||||
const [savingPw, setSavingPw] = useState(false)
|
||||
const [resendingVerify, setResendingVerify] = useState(false)
|
||||
|
||||
const [message, setMessage] = useState('')
|
||||
const [error, setError] = useState('')
|
||||
@@ -54,7 +55,20 @@ function AccountSettingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleChangePassword = async (e) => {
|
||||
const handleResendVerification = async () => {
|
||||
const em = user?.email
|
||||
if (!em) return
|
||||
setResendingVerify(true)
|
||||
try {
|
||||
await api.resendVerification(em)
|
||||
showOk('Falls diese Adresse einen unbestätigten Account hat: E-Mail ist unterwegs — Postfach prüfen.')
|
||||
} catch (err) {
|
||||
showErr(err.message || 'Konnte keine E-Mail senden.')
|
||||
} finally {
|
||||
setResendingVerify(false)
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault()
|
||||
if (newPw1.length < 4) {
|
||||
showErr('Neues Passwort: mindestens 4 Zeichen.')
|
||||
@@ -146,6 +160,18 @@ function AccountSettingsPage() {
|
||||
noch nicht bestätigt
|
||||
</span>
|
||||
)}
|
||||
{!verified && user?.email ? (
|
||||
<div style={{ marginTop: '0.75rem' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={resendingVerify}
|
||||
onClick={handleResendVerification}
|
||||
>
|
||||
{resendingVerify ? 'Sende…' : 'Bestätigung erneut senden'}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSaveName}>
|
||||
|
||||
Reference in new issue
Block a user