account.get() does not check if Appwrite account is still linked with Google auth.
- 0
- Self Hosted
- Web
unlink google account
button goes to the unlink google account page
and yk the user can unlink
this page
isn't that a bit problematic because on my side, the only form of auth is google π€
For good user experience, you can delete the session afterwards automatically, and they wont be able to sign-in again. Keep in mind this leaves a "zombie" account which cannot be accessed, but isn't deleted; you still store their data.
My recommendation here would be ability to delete, or block the account instead.
In my opinion, unlink makes more sense where there are multiple providers, and you want to unlink a specific one (often to link to same provider but with another account)
by delete the session afterwards automatically, how would i be able to do that?
like a) on button press, session is deleted b) or when detect unlinked, session is deleted
?
also the zombie account is fine
OAuth providers usually allow a redirectURL - they redirect user there after changing configurations to OAuth permissions.
So that would be B).
But honestly, A) doesnt sound too bad - if they decide not to delete and come back, they can simply sign-in again. And it's simpler to implement than B)
say we go for B,
how would that work?
because the only solution that I could find was to use user = account.get()
and see what's inside user.prefs
but theres nothing in there
oh the other way was to get the oauth google token and check that with google's own API but idk how to get the token
You can do account.getSession('current')
, and it sohuld have both refresh token, and access tokens (tokens used to do calls to Google APIs on behalf of the user)
oh whaaatt ok
so im assuming its just like
try {
account.getSession('current');
} catch (e) {
console.log("Unable to log in user", e);
handleLogout(); // or whatever
}
or would account.getSession('current')
return something
That would check for Appwrite user, same as account.get()
. You need something like (pseudo code)
session = accoutn.getSession(current)
token = session.accessToken
response = fetch(api.google.com/v1/users, {
headers: { authroization: token }
})
if(response.ok is false) {
handleLogout();
}
ok lemme take a look
Recommended threads
- Adding Phone Number During User Registra...
Hi everyone I'm working on integrating user registration in my application and need to include a phone number as a mandatory field. I understand that the accou...
- Self Hosting accessing AppWrite Console ...
Hey folks, I'm building out an application that helps people design offshore windfarms and looking to leverage AppWrite. I've used the hosted version for a cou...
- 401 to get /accounts
```javascript code: 401, type: 'general_unauthorized_scope', response: { message: 'User (role: guests) missing scope (account)', code: 401, ty...