Reputation: 387
I cannot comment on answers so I have to ask this question, I apologize.
I am getting an error on Xcode when trying to re authenticate the user so their email and or password is changed.
Here is the code I've written.
var credential: AuthCredential
let user = Auth.auth().currentUser
// re authenticate the user
user?.reauthenticate(with: credential) { error in
if let error = error {
// An error happened.
} else {
// User re-authenticated.
}
}
}
I get an error that states Cannot convert value of type '(_) -> ()' to expected argument type 'AuthDataResultCallback?' (aka 'Optional<(Optional, Optional) -> ()>')
Upvotes: 1
Views: 162
Reputation: 2639
It looks like the reauthenticate function returns a tuple, so you have to change the code:
var credential: AuthCredential
let user = Auth.auth().currentUser
// re authenticate the user
user?.reauthenticate(with: credential) { (authDataResult, error) in
if let error = error {
// An error happened.
} else {
// Use `user` property of result to check is successful.
}
}
Upvotes: 2