Does anyone know how Facebook login interacts with the email field? If a new user logs in via Facebook, does the ‘Users’ email field get populated with their primary email address registered with Facebook? Or, if a user is already registered in my Anvil app using their primary Facebook email address, will anvil login them into their correct account if they later try logging in via Facebook? (What if the email address is associated with their Facebook account, but not as the primary address?
Thanks!
2 Likes
Great questions… I have the same questions for Google login.
1 Like
For Google, I can report that if you register an account the ordinary way, putting a gmail address as the email and choosing a password, you get logged into the same account if you later use the Google login (with the same gmail address).
What I hadn’t previously thought of, though, is what would happen if you first login via Google but later register for an account the ordinary way using the gmail address as the email address. Will it let you, or tell you that that email address is already taken?
(If no one has the answers, I’ll be testing these things out over the next couple days, and I’ll report back.)
I can confirm that for all of “Email and password”, “Google”, “Facebook” and “Azure AD” login methods, we use the account’s primary email address, and match it against the email
column. This means that if I log into an app as meredydd@anvil.works
, it doesn’t matter whether I logged in via Google or with a password – I’ll be in the same account.
(If you want, you can of course build a different policy. Authenticate the user however you like – whether with a built-in service like Google or something hand-rolled – find the row in the Users table corresponding to the user you want to log in as, then call anvil.users.force_login()
with that row.)
2 Likes