删除firebase中的用户



我有一个删除当前登录用户的功能:

auth.currentUser.delete().then(logoutOfApp)
.catch((error) => alert(error)));

它工作得很好,但我想让某人成为管理员,所以我希望他可以选择删除其他帐户,所以有办法这样做吗?

auth.something(UserID of the user that i want to delete).delete()

在后端使用firebase admin NPM包;

app.get('/delete', function (req, res) {
const sessionCookie = req.cookies.session || '';
res.clearCookie('session');
if (sessionCookie) {
// Verify user and then delete the user.
admin.auth().verifySessionCookie(sessionCookie, true).then(function(decodedClaims) {
return admin.auth().deleteUser(userIdToDelete);
})
.then(function() {
// Redirect to login page on success.
res.redirect('/');
})
.catch(function() {
// Redirect to login page on error.
res.redirect('/');
});
} else {
// Redirect to login page when no session cookie available.
res.redirect('/');
}
});

最新更新