angular - How to delete user account from firebase with angular
问题描述
I have some users and this user has roles , lawyers can delete clients and admins can delete lawyers and clients , but when i am logged in as admin i can delete another user because i can get idToken of another user because to get the idToken i need to login with this user and i am logged in with my admin user and i only have my idToken no the token of the another user. can anyone help me ?
i try this :
borrarUsario(usuario:UsuarioModel)
{
this.http.delete(`${this.url}/Usuarios/${usuario.FireBaseID}.json`).subscribe();
return this.http.post(`https://identitytoolkit.googleapis.com/v1/accounts:delete?key=${myKey}`,{"idToken":`${usuaro.FireBaseID}`});
}
but this response with error idToken Invalid because the idToken is not the Firebase ID , how can i get the idToken witouth login with the another user
解决方案
Firebase Admin SDK提供了用户管理所需的工具。
一种选择是利用Cloud Functions for Firebase来运行 Admin SDK,例如,使用HTTP tiggers。
或者在您的服务器上使用 Admin SDK。开箱即用支持以下语言:
- JavaScript (Node.js)
- 爪哇
- Python
- 去
- C#
使用 Node.js 删除用户
admin.auth().deleteUser(uid)
.then(function() {
console.log('Successfully deleted user');
})
.catch(function(error) {
console.log('Error deleting user:', error);
});
请参阅管理用户:删除用户
推荐阅读
- tableau-api - 计算适用于相对日期过滤器的运行总计
- css - React-bootstrap 按钮动画将不起作用并且按钮不会居中
- javascript - 如何测试 data-cy 指令?
- heroku - 将 Koa Routes 与 Heroku 一起使用会返回 404 错误
- python-3.x - 在接近零的列表中查找更多索引
- excel - 在打开多个 excel 文件的情况下运行 VBA 代码(宏) - 如何正确编码和声明
- javascript - 为相同的属性添加对象和数组
- ubuntu - 如何从我的 ubuntu 18.04 机器中删除 tomcat 9 安装?
- c++ - 以未知格式输出的二次方程求解器
- mysql - 使用 mysql 和正则表达式模式转换和提取行