This function fails to save the user to the DB after login:
TypeScript
export async function loginUsingGoogle() {
await account.createOAuth2Session(
OAuthProvider.Google,
"http://localhost:3000/verification",
"http://localhost:3000/sign-in"
);
const user = await account.get();
try {
await databases.getDocument("development", "users", user.$id);
} catch {
const imageUrl = avatar.getInitials(user.name);
await databases.createDocument("development", "users", user.$id, {
email: user.email,
name: user.name,
imageUrl,
});
}
}
I'm assuming the reason for that is that the page gets redirected to the external auth page. So how do I add a user to the DB after a successful login?
TL;DR
The function to save the user to the DB after OAuth login is failing due to redirection to the external auth page. To resolve this, consider updating the code flow to handle the successful login scenario after the redirection. This could involve implementing a callback function or handling the user creation logic after successful authentication.Recommended threads
- how to access the value of account statu...
- Email address must be in its canonical f...
Hello, Recently I was trying to signup with my GitHub account with appwrite account for availing the student benifits but while trying to signup I saw such erro...
- Login / Signup issue
So I have been trying to create an account on appwrite but no matter what I try it doesn't work. I tried using GitHub at first but after logging in it just red...