[ad_1]
I’m making an attempt to create a reset password expertise inside my app utilizing firebase. I am calling sendPasswordReset(withEmail:completion), I am dealing with the dynamic hyperlink in order that it opens the app and masses a view controller to enter and make sure a brand new password. That is working properly. I am caught at what to do subsequent. I discovered the next strategies for resetting the password however am getting errors and I do know I am lacking one thing or simply doing it fully improper.
DynamicLinks.dynamicLinks().handleUniversalLink(url) { dynamicLink, error in
guard error == nil else {
setupInitialView()
return
}
guard let authURL = dynamicLink?.url else { return }
showResetPasswordLinkHandling(withURL: authURL)
}
then as soon as I am within the VC I take advantage of that dynamic hyperlink for calling the firebase strategies:
updatePassword(withCode: resetURL.absoluteString, password: password) { (success, errorMessage) in
completion(success, errorMessage)
}
...
personal let firebaseAuth = Auth.auth()
...
func updatePassword(withCode code: String, password: String, completion: FirebaseCompletion) {
firebaseAuth.verifyPasswordResetCode(code) { [weak self] consequence, error in
guard let self = self else { return }
guard let password = consequence else {
if let error = error {
let errorMessage = error.localizedDescription
completion(false, errorMessage)
}
return
}
self.firebaseAuth.confirmPasswordReset(withCode: code, newPassword: password) { error in
if let error = error {
let errorMessage = error.localizedDescription
completion(false, errorMessage)
}
completion(true, "")
}
}
}
That is the error from verifyPasswordResetCode(code): “The motion code is invalid. This will occur if the code is malformed, expired, or has already been used.”
I am guessing dynamicLink?.url is not the fitting reset code. However I’ve not been capable of finding any data on the right way to make this work. Please Please assist… With examples if it isn’t asking an excessive amount of.
[ad_2]
