0
votes

I need to store email's verification status info in database in firebase. For example when an user create an email/password account with uid="001", I will create a node in database: '001':{emailverified: false}. And then when they verify this email I will update the node '001':{emailverified: true}

I tried by creating custom email action handlers. But the problem is that when user click the link to verify his email, I can not get the user's uid from the oobCode. So I can not find a way to update email's verification in the database.

1

1 Answers

2
votes

Not sure why you want to store this information in your database as Firebase already stores it for you.... but you can do something like this to get the value of the email verification. I'd just check it when they attempt to login and update the value in your database. Again not sure why you want to store this.

func login() {
    Auth.auth().signIn(withEmail: emailField.text!, password: passwordField.text!, completion: {(user, error) in
        if let error = error {
            // alert user of the error 
        }
        if user != nil && user!.isEmailVerified {
            // upload true to your database         
        }
        else if user != nil && !user!.isEmailVerified {
            // upload false
        }    
    })
}

You might also be able to use:

Auth.auth().currentUser.isEmailVerified // not sure if this works