我只想使用旧密码和新密码,而不是通过在swift2中使用firebase发送重置链接到应用程序中的电子邮件来更改密码

时间:2017-01-26 04:36:11

标签: firebase swift2 firebase-authentication

在android中,我使用reauthenticate但是在swift中,我可以使用哪种方式?例如,在像这样的机器人

Firebase.getCurrentUser().reauthenticate(EmailAuthProvider.
                                    getCredential(Firebase.getCurrentUser().getEmail(),old_pass))
                                    .addOnSuccessListener(new OnSuccessListener<Void>() {
                                        @Override
                                        public void onSuccess(Void aVoid) {
                                           //add some code
                                        }
                                    })
                                .addOnFailureListener(new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {
                                   //add some code
                                }
                            });
                        }});

1 个答案:

答案 0 :(得分:1)

根据Firebase文档,这应该有效:

let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential

let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential

// Prompt the user to re-provide their sign-in credentials

user?.reauthenticate(with: credential) { error in
  if let error = error {
    // An error happened.
  } else {
    // User re-authenticated.
  }
}

这是我的来源:https://firebase.google.com/docs/auth/ios/manage-users#re-authenticate_a_user