Is it possible to have a non-anonymous user? I want to have a passwordless email only signin, the user receives an email and confirm his email. Then I want to toggle isAnonymous to false.
My code:
const { user } = await signInAnonymously(auth)
await updateEmail(user, email)
await sendEmailVerification(user)
setInterval(() => auth.currentUser.reload(), 2000)
As you can see the user verified his email but still isAnonymous
Edit
Not possible, the user won't be able to sign in. Every time the user tries to sign in he will create a new anonymous user which when updating the user (await updateEmail(user, email)) will result in auth/email-already-in-use.
You need to change your authentication mechanism here.
First, you need to create a custom Endpoint to check the user's email address on the backend and in response the backend will send firebase custom token using Firebase admin SDK. This is a JWT token which will be used on the frontend for authenticating with firebase.
const uid = 'user-email';
getAuth()
.createCustomToken(uid)
.then((customToken) => {
// Send token back to client
})
.catch((error) => {
console.log('Error creating custom token:', error);
});
Secondly, on the frontend your application will authenticate with firebase using the following Firebase Client method.
firebase.auth().signInWithCustomToken(token)