Email verification not working as I would expect
I have a pretty simple BetterAuth set up. I am just trying to do a simple emailSignUp with email verification flow. I followed the docs page on email sign up.
in my signUp server action I have this:
I receive the email just fine, with the token:
Click the link to verify your email: http://localhost:3000/api/auth/verify-email?token=eyJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImxramFkc2ZAYXNkZi5jb20iLCJpYXQiOjE3NDcxNDQ3NDEsImV4cCI6MTc0NzE0ODM0MX0.4q3y1JxTFGK4joYJrsat-2sTZRj3vAY05PnaonYogXk&callbackURL=/
When I click on that link, I get the attached screenshot int he network tab.
No errors, no feedback.
No entries in my
mytable_verifications
either. The signUp creates an account, and I can sign in with that account right away.
4 Replies
I think because I am doing stuff server-side things are different?
Also, I notice that the users table has a verified t/f column. When I do a signUpEmail, the user is verified False, which is correct. But they still get a session cookie that allows them to access protected pages.
So if I do things server side, am I expected to check if the user is verified on a server side page, and then show them a verification is required to continue?
EMail Verified by default is irellevant to authentification status of the User
You can however set a flag somewhere to require a verified email to allow logging in
Mb. didnt see you had it active, then I wonder why the user gets logged in if the email is not verified
Ah I see I have "autoSignIn" set to false additionally, that might be what allows users in your case to instantly login on signup
Options | Better Auth
Better Auth configuration options reference.
I think its because authentication and authorization are different things - which checks out, albeit confusing
I think the user specifying the correct email and password technically authenticates them, but then its still up the application to decide whether or not to authorize them.