If not, how can I verify the emails of users which would be registering using email otp?
OTP is the secret, so it should be fine.
If that's the case, then why am I getting these error?
can you show some relevant code?
sdk versions would be good too in the details.
`export const register = async (email, password, name) => { try { const user = await account.create("unique()", email, password, name); if (user) { // Automatically log in after registration account.createEmailToken(ID.unique(), email, true).then( function (response) { console.log("Success sending otp"); // Success return response; }, function (error) { console.log("Failure sending otp", error); // Failure } ); // const session = await account.createSession(user.$id, secret); secret is the otp return { success: true, // data: session.data, emailVerification: user.emailVerification, userId: user.$id, // Return userId for OTP verification }; } return { success: false, error: "Registration failed" }; } catch (error) { console.error("Registration error:", error); return { success: false, error: error.message }; } };
export const verifyOTP = async (userId, secret) => { console.log("userId", userId, "\nOTP: ", secret); try { const response = await account.updateVerification(userId, secret); //I think it doesn't works with the otp response.then( function (response) { console.log("Verification was successful! \n", response); // Success }, function (error) { console.log("there was some error verifying the user \n", error); // Failure } ); return { success: true, data: response }; } catch (error) { console.error("OTP verification error:", error); return { success: false, error: error.message }; } };`
idk about sdk version but I am using appwrite 14.0.1
aah I see. My bad, you should be able to directly create a session. See - https://appwrite.io/docs/products/auth/email-otp
It means there is no way to verify a user through otp login?
looking at the source, once the session is created via magic-url or otp, the email should be marked as verified.
ooh, if that's the case. It would be nice!
Recommended threads
- Hi Folks, Database Writing Issue
Hey Folks im trying to get logging setup on my website but im getting an error, i dont have any document id and i think this is the issue but i havent got the f...
- Middleware
how to make middleware in nextjs appwrite with client side auth?
- Error 400: redirect_uri_mismatch
Hi team, Google OAuth was working fine with our Appwrite Cloud setup until yesterday. We did not change any configuration in Appwrite, Google Cloud, or our cod...