refactor: improve email verification handling in components
- Introduced a utility function to standardize email verification checks across EmailVerificationBanner and AccountSettingsPage. - Updated conditional logic to enhance clarity and maintainability regarding email verification status. - Ensured consistent treatment of various representations of email verification status in user profiles.
This commit is contained in:
1 parent
2646bc776a
commit
a748f4607d
2 files changed
+16
-4
No files matched your search
@@ -1,6 +1,12 @@
|
||||
import { useState } from 'react'
|
||||
import api from '../utils/api'
|
||||
|
||||
function isEmailVerifiedRow(p) {
|
||||
if (!p) return false
|
||||
const v = p.email_verified
|
||||
return v === true || v === 't' || v === 1 || v === 'true'
|
||||
}
|
||||
|
||||
/**
|
||||
* Hinweis + „Erneut senden“, wenn eingeloggt aber E-Mail noch nicht verifiziert (wie Mitai).
|
||||
*/
|
||||
@@ -9,7 +15,7 @@ export default function EmailVerificationBanner({ profile }) {
|
||||
const [success, setSuccess] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
|
||||
if (!profile?.email || profile.email_verified !== false) return null
|
||||
if (!profile?.email || isEmailVerifiedRow(profile)) return null
|
||||
|
||||
const handleResend = async () => {
|
||||
if (!profile.email) return
|
||||
|
||||
Reference in new issue
Block a user