I am developing an application with a new firebase from google. And I have a problem updating my email and password.
Here is what I have tried.
let currentUser = FIRAuth.auth()?.currentUser currentUser?.updateEmail(email) { error in if let error = error { print(error) } else { // Email updated. currentUser?.updatePassword(password) { error in if let error = error { } else { // Password updated. print("success") } } } }
But when updating the password, such an error occurs.
"Domain = FIRAuthErrorDomain Code = 17014" This operation is sensitive and requires recent authentication ... "
As I know, we must reconfigure the user after updating the email.
I tried to reconfigure from firebase with this code.
let user = FIRAuth.auth()?.currentUser var credential: FIRAuthCredential // Prompt the user to re-provide their sign-in credentials user?.reauthenticateWithCredential(credential) { error in if let error = error { // An error happened. } else { // User re-authenticated. } }
But this error occurs
Credential Variables Used Before Initialization
I know this because I donโt initialize the credentials variable, but I donโt know how to fix it.
Is there anyone who knows the solution?
source share