비밀번호를 업데이트 할 때 현재 비밀번호와 새 비밀번호를 입력하길 원합니다.Firebase 3에서 비밀번호를 변경할 때 사용자의 현재 비밀번호를 확인하는 방법은 무엇입니까?
Firebase 설명서를 검색했지만 사용자의 현재 비밀번호를 확인할 방법을 찾지 못했습니다.
가능하면 누구에게 알리십니까?
비밀번호를 업데이트 할 때 현재 비밀번호와 새 비밀번호를 입력하길 원합니다.Firebase 3에서 비밀번호를 변경할 때 사용자의 현재 비밀번호를 확인하는 방법은 무엇입니까?
Firebase 설명서를 검색했지만 사용자의 현재 비밀번호를 확인할 방법을 찾지 못했습니다.
가능하면 누구에게 알리십니까?
암호를 변경하기 전에 reauthenticate을 사용하여이 문제를 해결할 수 있습니다.
let user = FIRAuth.auth()?.currentUser
let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email, password: currentPassword)
user?.reauthenticateWithCredential(credential, completion: { (error) in
if error != nil{
self.displayAlertMessage("Error reauthenticating user")
}else{
//change to new password
}
})
그냥 당신이 사용하는 어떤 공급자에 대한 자격 증명 개체를 설정하는 방법을 찾을 수 있습니다
here 자세한 정보를 추가 할 수 있습니다. 스위프트 4
가 :
typealias Completion = (Error?) -> Void
func changePassword(email: String, currentPassword: String, newPassword: String, completion: @escaping Completion) {
let credential = EmailAuthProvider.credential(withEmail: email, password: currentPassword)
Auth.auth().currentUser?.reauthenticate(with: credential, completion: { (error) in
if error == nil {
currentUser.updatePassword(to: newPassword) { (errror) in
completion(errror)
}
} else {
completion(error)
}
})
}
중포 기지 문서가
here를 찾을 수 있습니다 그것은했다. 대답으로 표시했습니다. 감사. –
@AmadeuAndrade Nice! 다행 했어! – adolfosrs