How to check the user's e-mail confirmation status upon log-in from Supabase & Invalid Credentials
Answered
Sun bear posted this in #help-forum
Sun bearOP
I'd like to give the user a visual cue that they need to confirm their e-mail first, before being able to log-in.
Currently I only get "Login error: Email not confirmed" in the terminal but I'm not sure how to actually get this status from Supabase itself on the server side so that I can then update my UI accordingly based on that when the user tries to log-in (I suppose that's how it would normally be done).
I'd like to do the same for when the credentials are invalid.
Here's my code:
Login form code: https://paste.ec/paste/FaLdZzLf#S2q8U-59rtMRDZW0RENU1JBus1FIpgmUa9QoGwC2Xg7
Login Page code: https://paste.ec/paste/bA0Zv+Jc#p1hLESegekiVZmlUxKS8d2-vdiWTlWOr6V01hfMKO4k
Server action code: https://paste.ec/paste/QxkchBFS#BKZtdc3Fb4PBeYgVkBWQhzDKlthF+KJSA+ZIpcJww2g
I've also linked a screenshot from my prototype so that you guys can better understand what I'm trying to do.
Currently I only get "Login error: Email not confirmed" in the terminal but I'm not sure how to actually get this status from Supabase itself on the server side so that I can then update my UI accordingly based on that when the user tries to log-in (I suppose that's how it would normally be done).
I'd like to do the same for when the credentials are invalid.
Here's my code:
Login form code: https://paste.ec/paste/FaLdZzLf#S2q8U-59rtMRDZW0RENU1JBus1FIpgmUa9QoGwC2Xg7
Login Page code: https://paste.ec/paste/bA0Zv+Jc#p1hLESegekiVZmlUxKS8d2-vdiWTlWOr6V01hfMKO4k
Server action code: https://paste.ec/paste/QxkchBFS#BKZtdc3Fb4PBeYgVkBWQhzDKlthF+KJSA+ZIpcJww2g
I've also linked a screenshot from my prototype so that you guys can better understand what I'm trying to do.
Answered by averydelusionalperson
45 Replies
also, I think it's better if you infer zod schema type instead of creating your own type for form types
@averydelusionalperson also, I think it's better if you infer zod schema type instead of creating your own type for form types
Sun bearOP
Uhh no idea how that is done
And my AI is down at the moment so I can't use that
@averydelusionalperson can you console.log this
Sun bearOP
Same for this
@Sun bear Same for this
hmm, what. just do
console.log(signInError). without the ?.message@averydelusionalperson Click to see attachment
Sun bearOP
Okay so I just need to update it like in the image ?
@Sun bear Okay so I just need to update it like in the image ?
yeah, you can keep the schema same as yours, just use the type like I did
const loginSchema = z.object({
email: z.string().email({ message: t("invalidEmailError") }),
password: z.string().min(6, { message: t("passwordMinLengthError") }),
});
const loginSchemaType = z.infer<typeof loginSchema>;^ like this
@averydelusionalperson also, I think it's better if you infer zod schema type instead of creating your own type for form types
Sun bearOP
Hold on, so I first need to delete this right ?
@Sun bear Hold on, so I first need to delete this right ?
yeah, you prolly should
use the auto generate type instead
I keep all the schema, and types in one file. so I can use it in both, form, and server actions.
Sun bearOP
So I just delete this snippet first right ?
Sun bearOP
Okay
@averydelusionalperson ts
const loginSchema = z.object({
email: z.string().email({ message: t("invalidEmailError") }),
password: z.string().min(6, { message: t("passwordMinLengthError") }),
});
const loginSchemaType = z.infer<typeof loginSchema>;
Sun bearOP
And I paste this in place of it or in another place in the code
?
Does the order / placement matter ?
Man, this is so hard without AI 😅
@Sun bear Does the order / placement matter ?
I don't think so
@averydelusionalperson I don't think so
Sun bearOP
Okay so I get some errors after pasting that snippet in
you're having errors localized as well?
Sun bearOP
I think so yes, and if they aren't I'll localize them (including the visual cues we're trying to add now)
Everything needs to be localized
hmm, okay then, I think for now keep it as it is. I don't have idea about localizations, IDK if you need to use translations on the server component, and not on different file.
let's solve supabase issue for now
Sun bearOP
Yeah, someone made a suggestion in off topic
Maybe we can try that ?
I reverted it to how it was for now
@Sun bear I think you should close the thread
Sun bearOP
Umm well
I think it's better to leave it open until I can try to do it with the AI in case I encounter issues
oh, if you want then sure, I just wanted so, the helpers usually don't mingle much in already opened thread
they are lazy to read all the previous messages in the thread
Sun bearOP
Yes but I have you in here 😁
lmao, fair enough
I'm always online
Sun bearOP
I've updated my code but it still doesn't show the error yet.
Login Form: https://paste.ec/paste/xZ1MDxZd#7urAN1LKmIeoQC5Ae86meL8Qr9GNCy2hBBuI2Zj4l34
Server Action:
https://paste.ec/paste/QeLFmhf-#ieIFS+gvWYL+J8I4dnzaXIEz4BeK6UnGIOhtXh-eWQZ
Login Form: https://paste.ec/paste/xZ1MDxZd#7urAN1LKmIeoQC5Ae86meL8Qr9GNCy2hBBuI2Zj4l34
Server Action:
https://paste.ec/paste/QeLFmhf-#ieIFS+gvWYL+J8I4dnzaXIEz4BeK6UnGIOhtXh-eWQZ
Sun bearOP
😮 It worked!