我想删除通过您的密钥进行身份验证的用户,因为我知道我是一名管理员,因此我创建了一个authservice,并且在userService之后与注册用户相关联。
现在,在数据库中,我有一个关联用户
现在,在我的代码中,我创建了在auth.service.ts中创建用户的方法
createUser(user: any, path: string) {
return this.afu.auth.createUserWithEmailAndPassword(user.email, user.password)
.then(() => {
return this.service.save(user, path);
})
.catch((e) => console.log(e));
}
此方法创建经过身份验证的用户,并在数据库中创建用户,并调用方法保存
save(user: any, path: string) {
const createdAt = new Date();
return new Promise((resolve, reject) => {
this.db.list(this.PATH + path)
// .push(user)
// console.log(createdAt)
.push({ name: user.name, email: user.email, role: user.role_id, status: user.status, created_at: createdAt })
.then(() => resolve())
})
}
因此,我必须在我的方法中按键删除这两个寄存器。
remove(key: string, path: string) {
return this.db.list(this.PATH + path).remove(key);
}
记住,我是管理员
发布于 2018-05-05 14:32:42
从您的评论中,我了解您希望“从身份验证中删除用户”。使用User的delete()方法,请参阅https://firebase.google.com/docs/reference/js/firebase.User
使用Auth服务接口的currentUser()
方法获取当前用户,请参见https://firebase.google.com/docs/reference/js/firebase.auth.Auth#currentUser
在“纯”JavaScript中,您可以执行以下操作,使用邮件的用户user@mail.com将从身份验证列表中删除。
firebase.auth().signInWithEmailAndPassword("user@mail.com", "abcd")
.then(function (info) {
var user = firebase.auth().currentUser;
user.delete();
});
https://stackoverflow.com/questions/50183814
复制相似问题