Is there any way to do email confirmation for Firebase user creation and/or password reset?

前端 未结 9 2217
故里飘歌
故里飘歌 2020-11-28 04:03

Question says it all. In Firebase, how do I confirm email when a user creates an account, or, for that matter, do password reset via email.

I could ask more broadly:

9条回答
  •  借酒劲吻你
    2020-11-28 04:57

    I used following code to check the email verification after creating new account.

    let firAuth = FIRAuth.auth()
    firAuth?.addAuthStateDidChangeListener { auth, user in
        if let loggedUser = user {
    
            if loggedUser.emailVerified == false {
    
                loggedUser.sendEmailVerificationWithCompletion({ (error) in
    
                    print("error:\(error)")
                })
            }
            else {
    
                print(loggedUser.email)
            }
        } else {
            // No user is signed in.
            print("No user is signed in.")
        }
    }
    

提交回复
热议问题