Home > Blockchain >  Can I send email verification every time the user login instead of using password in firebase (Flutt
Can I send email verification every time the user login instead of using password in firebase (Flutt

Time:07-06

For some reason, I don't want the users to register and login with password in my Flutter application using Firebase, Is there any way to let the user enter his email only, then I send email verification to his email every time he login. Also I don't want to register using phone number.

CodePudding user response:

There are two options, you can create and have a user with no password.

Using provider:

export function signInUsingProvider(providerDomain: string) {
    return signInWithPopup(getAuth(), new OAuthProvider(providerDomain))
}

signInUsingProvider('google.com')

You ask the browser to give you some information about user logged in google.com account and browser gives you some information about this user, so you can authenticate him. Email will be verified automatically.

Sign in with email link:

const actionCodeSettings = {
  // URL you want to redirect back to. The domain (www.example.com) for this
  // URL must be in the authorized domains list in the Firebase Console.
  url: 'https://www.example.com/finishSignUp?cartId=1234',
  // This must be true.
  handleCodeInApp: true,
  iOS: {
    bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  dynamicLinkDomain: 'example.page.link'
};

sendSignInLinkToEmail(getAuth(), email, actionCodeSettings)

Basically, it sends an email with a link with will authenticate you. For more details, visit Firebase documentation.

Remember that if you have not set password, you cannot for example delete an account!

CodePudding user response:

What you're describing is known as the email link provider in Firebase, which sends an email message with a link to sign-in.

  • Related