Jus*_*s10 4 firebase firebase-authentication angularfire2 angular
我可以轻松地使用它来创建用户:
this.af.auth.createUser({email: email, password: password});
Run Code Online (Sandbox Code Playgroud)
但是一旦创建用户详细信息,我该如何编辑它们?(即:更改密码或电子邮件地址?)。我会认为是这样的:
this.af.auth.updateUser({email: email, password: password});
Run Code Online (Sandbox Code Playgroud)
但是没有updateUser方法吗?
小智 6
With AngularFire2 you just need to add "currentUser" to your path.
this.af.auth.currentUser.updateEmail(email)
.then(() => {
...
});
Run Code Online (Sandbox Code Playgroud)
You will also need to reauthenticate the login prior to calling this as Firebase requires a fresh authentication to perform certain account functions such as deleting the account, changing the email or the password.
For the project I just implemented this on, I just included the login as part of the change password/email forms and then called "signInWithEmailAndPassword" just prior to the "updateEmail" call.
To update the password just do the following:
this.af.auth.currentUser.updatePassword(password)
.then(() => {
...
});
Run Code Online (Sandbox Code Playgroud)
我曾经遇到过这个问题,但还没有得到 angularfire2 的答案。
这是我解决这个问题的原生 firebase 方法。
public auth: any;
constructor(@Inject(FirebaseApp) firebaseApp: any) {
this.auth = firebaseApp.auth();
}
reset(targetEmail: any) {
this.auth.sendPasswordResetEmail(targetEmail);
}
Run Code Online (Sandbox Code Playgroud)
笔记:
看来我们无法直接更改密码,只能发送密码重置电子邮件到目标电子邮件地址。
| 归档时间: |
|
| 查看次数: |
4200 次 |
| 最近记录: |