BA
Better Auth•3mo ago
Ping

on verifying email OTP, it fails.

After successfully sending an email containing the OTP for verification, the moment I enter it, and click verify, I get an internal 500 error stating:
No description
53 Replies
Ping
PingOP•3mo ago
Additional info: * EmailOTP plugin has zero separate configuration besides the email to send itself via the sendVerificationOTP fn. * plugins in use: * passkey * phoneHarmony * phoneNumber * emailHarmony * namePlugin - custom * agreementPlugin - custom * recieveEmailsPlugin - custom * jwt * bearer * emailOTP * validator - better-auth-validator * twoFactor * admin * organization * multisession * nextCookies (last in array) * Zero separate custom db hooks * On latest BetterAuth version. --- I rolled back Better-Auth to version 1.0.10 and it all works again. So either I missed a breaking change which seems unlikely considering 1.0.10 to 1.0.22 is just patch updates, or there is a bug in BetterAuth.
bekacru
bekacru•3mo ago
have you by any chance set autoSignInAfterVerification to true
Ping
PingOP•3mo ago
I did, then disabled it to test, same issue. (this was before rolling back to .10)
bekacru
bekacru•3mo ago
the only change we had since 1.0.10 is that we now check for autoSignInAfterVerification and we sign the user in
Ping
PingOP•3mo ago
I'll go back to latest and test again With autoSignInAfterVerification not set, I receive the same error. With it set, I still get the same error. @bekacru Do you think this is a BetterAuth bug or a bug on my end? It doesn't make sense that all issues go away the moment I roll back to an older version though...
bekacru
bekacru•3mo ago
so does this happen when you call client.emailOtp.verifyEmai? we have tests, I don't think it's something silly.
Ping
PingOP•3mo ago
const user = await authClient.emailOtp.verifyEmail({
email: email,
otp: otp,
});
const user = await authClient.emailOtp.verifyEmail({
email: email,
otp: otp,
});
Yeah. So then it's something on my end.
bekacru
bekacru•3mo ago
okay my guess is, updateUser call is returning null somehow. what are you using for db adapter?
Ping
PingOP•3mo ago
No description
Ping
PingOP•3mo ago
FYI: Signing up does add a row to user & account.
bekacru
bekacru•3mo ago
yeah I think this might be because of the drizzle adapter mysql update returning is broken mysql doesn't support returning after update we're overriding that by querying again after an update if you can, check with another db like sqlite
Ping
PingOP•3mo ago
Do you know of a good way to easily set it up?
bekacru
bekacru•3mo ago
just change the provider to sqlite and setup drizzle to use sqlite instead
Ping
PingOP•3mo ago
Sorry, I mean to setup sqlite itself. I guess I can try better-sqlite or whatever that package is.
bekacru
bekacru•3mo ago
yeah see the drizzle docs
Ping
PingOP•3mo ago
Yeah I got it. Testing it now.. On sqlite, with autoSignInAfterVerification set to true, it works. And with it undefined, it still works. @bekacru
bekacru
bekacru•3mo ago
yeah will fix the mysql issue thanks!
Ping
PingOP•3mo ago
🙂 Let me know when it's fixed, I can then test it out for you if you need it. @bekacru I'm using the old version while it works for mysql, but while signing up it works successfully, the moment I go to my app, I get redirected to my sign-in page essentially saying I don't have an active session. Any ideas to why I don't get sessions? Even going to my sign-in route, typing my details and singing in successfully, the moment I reload the page and check the console, it says my session is null... The newer versions would probably have already fixed this issue, but I can't upgrade until mysql works. And until I get this auth working, I can't work on my app.
bekacru
bekacru•3mo ago
check if the cookie is being properly set after you signIn also for mysql issue for the time being you can use the built in adapter (kysley) and it should work.
Ping
PingOP•3mo ago
Better Auth handles assigning cookies for me, right?
bekacru
bekacru•3mo ago
yeah just check on the browser if a cookie is set
Ping
PingOP•3mo ago
Yeah, there's a cookie set.
Ping
PingOP•3mo ago
Is it weird that there is multiple?
No description
bekacru
bekacru•3mo ago
these are related to multi-session remove all of them remove the multi-session plugin and check if it works first
Ping
PingOP•3mo ago
Ping
PingOP•3mo ago
Oh, sure. Keep in mind, this is 1.0.10
Ping
PingOP•3mo ago
That's interesting... it just disappeared?
bekacru
bekacru•3mo ago
what plugins are you using? try disbaling all plugin first
Ping
PingOP•3mo ago
No description
Ping
PingOP•3mo ago
I disabled all but NextCookies. Testing now.
Ping
PingOP•3mo ago
Well, it works now.
Ping
PingOP•3mo ago
It's now a guessing game 🤣
bekacru
bekacru•3mo ago
you should first check two factor
Ping
PingOP•3mo ago
ruled out means it's not the problem * passkey * phoneHarmony * phoneNumber * emailHarmony * namePlugin - custom * agreementPlugin - custom * recieveEmailsPlugin - custom * jwt * bearer <- issue * emailOTP * validator - better-auth-validator * twoFactor * admin * organization * multisession * nextCookies (last in array) With everything enabled besides bearer, it works. Any ideas?
bekacru
bekacru•3mo ago
not sure but the new release should probably fix it
Ping
PingOP•3mo ago
Umm.
No description
Ping
PingOP•3mo ago
Let me go check my tsconfig. Just to make sure. Tsconfig is fine.
Ping
PingOP•3mo ago
No description
Ping
PingOP•3mo ago
Okay I reloaded ts-server and most errors went away.
Ping
PingOP•3mo ago
Did you remove passkey from the export from index.ts? since all of a sudden now I need to import passkey from it's specific path
No description
Ping
PingOP•3mo ago
--- When verifying the OTP, I still get this error.
No description
Ping
PingOP•3mo ago
Oh yeah, mysql don't work with BetterAuth.
bekacru
bekacru•3mo ago
yeah I think we forgot mentinong that on the release notes btw it should work currently if you don't disable auto id generation the error is related to mysql + disabled auto id generation feel free to open gh issue
Ping
PingOP•3mo ago
I don't think I touched auto id gen
bekacru
bekacru•3mo ago
so advanced.generateId isn't set to false or anything?
Ping
PingOP•3mo ago
the only thing in advanced
No description
bekacru
bekacru•3mo ago
hmm that's weird. are you using drizzle adapter?
Ping
PingOP•3mo ago
yes
bekacru
bekacru•3mo ago
if you're using mysql and not plantescale use the built in adapter you can pass the mysql instance directly
Ping
PingOP•3mo ago
I'm using planetscale unfortunate I guess 😅
bekacru
bekacru•3mo ago
no worries. it'll be fixed on the next release!
Ping
PingOP•3mo ago
Awesome, thanks so much Love the dedication you have
Unknown User
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?