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,10 +13,16 @@ const API_URL = import.meta.env.VITE_API_URL || ''
|
||||
*/
|
||||
async function request(endpoint, options = {}) {
|
||||
const token = localStorage.getItem('authToken')
|
||||
const method = (options.method || 'GET').toUpperCase()
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers
|
||||
...options.headers,
|
||||
}
|
||||
// GET ohne Body: kein Content-Type: application/json (manche Proxies/Headers stören sich)
|
||||
if (method !== 'GET' && method !== 'HEAD') {
|
||||
if (!headers['Content-Type'] && !headers['content-type']) {
|
||||
headers['Content-Type'] = 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
if (token) {
|
||||
@@ -107,6 +113,21 @@ export async function changePassword(newPassword) {
|
||||
})
|
||||
}
|
||||
|
||||
/** GET /api/auth/verify/{token} — keine Auth nötig; Token gehört zur URL des Bestätigungslinks */
|
||||
export async function verifyEmail(token) {
|
||||
const t = encodeURIComponent(token)
|
||||
return request(`/api/auth/verify/${t}`, {
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
export async function resendVerification(email) {
|
||||
return request('/api/auth/resend-verification', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email }),
|
||||
})
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Clubs & Groups
|
||||
// ============================================================================
|
||||
@@ -881,6 +902,8 @@ export const api = {
|
||||
getCurrentProfile,
|
||||
updateProfile,
|
||||
changePassword,
|
||||
verifyEmail,
|
||||
resendVerification,
|
||||
|
||||
// Clubs & Groups
|
||||
listClubs,
|
||||
|
||||
Reference in new issue
Block a user