Home > Blockchain >  Firebase isEmailVerified returns true even if mail isn't verified
Firebase isEmailVerified returns true even if mail isn't verified

Time:10-28

I'm having trouble with the verification process using firebase. My code looks like this:

        guard let user = Auth.auth().currentUser else {
           return self.logOutUser()
        }

        user.reload { (error) in
            switch user.isEmailVerified {
            case true:
                print("Users email is verified")
            case false:
                print("Users email is not verified")
                user!.sendEmailVerification { (error) in
                    guard let error = error else {
                        return print("Verification email sent")
                    }
                print(error)
                }
            }
        }

The problem I have is that even if I don't verify the mail with the verification mail that gets sent, after like 10s user.isEmailVerified returns true. Thankful for any help :)

CodePudding user response:

There are multiple ways that an email could be considered verified by Firebase Authentication.

Clicking on the link in a verification email is one of them, but as Dharmaraj commented, signing in with email link authentication is another.

In addition some providers may mark some email addresses as verified when they "own" that domain/relationship. Notable: signing into with Google with a gmail.com address is auto-verified, as is signing in with Facebook and a facebook.com address.

  • Related