Reauthenticate Swift User Credentials

I want to re-authenticate the user before allowing them to change their login information. However, due to a recent Firebase update, I found the documentation pretty useless. Using this link , I produced the following authenticateUser () function.

func authenticateUser() { let user = FIRAuth.auth()?.currentUser var credential: FIRAuthCredential //prompt user to re-enter info user?.reauthenticateWithCredential(credential, completion: { (error) in if error != nil { self.displayAlertMessage("Error reauthenticating user") } else { //user reauthenticated successfully } }) } 

However, I'm not sure what to do with the credential variable of type FIRAuthCredential to re-authenticate the user. The documentation for this class can be found here .

+6
authentication ios swift firebase firebase-authentication
source share
1 answer

The receipt of the FIRAuthCredential object depends on which provider you want to use for re-authentication.

Email:

 let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email, password: password) 

Facebook:

 let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString) 

Twitter:

 let credential = FIRTwitterAuthProvider.credentialWithToken(session.authToken, secret: session.authTokenSecret) 

Google:

 let authentication = user.authentication let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken) 
+18
source share

All Articles