最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to disable a user from firebase? - Stack Overflow

programmeradmin1浏览0评论

In the firebase API


we can delete users, but how could we prevent users from simply registering again, in the GUI for firebase we have the option to disable users , how could we do this in the program, for example if we are building a admin panel that checks posts for a listing site that have been reported, and we want to disable the creator or the reporter for spamming as part of availiable actions.

Thanks.

I develop in react if that changes the answer.

In the firebase API

https://firebase.google./docs/auth/web/manage-users

we can delete users, but how could we prevent users from simply registering again, in the GUI for firebase we have the option to disable users , how could we do this in the program, for example if we are building a admin panel that checks posts for a listing site that have been reported, and we want to disable the creator or the reporter for spamming as part of availiable actions.

Thanks.

I develop in react if that changes the answer.

Share asked Feb 18, 2020 at 19:59 user12551065user12551065
Add a ment  | 

4 Answers 4

Reset to default 8

To prevent the user from re-registering, you should disable account instead of deleting it. This will prevent the user from signing in again, and from refreshing their ID token. If you want to do this programmatically, have a look at updating a user with the Admin SDKs. For example, in Node.js it'd be:

admin.auth().updateUser(uid, { disabled: true })

Keep in mind however that even after disabling the account, their existing ID token will remain valid until it expires (typically within an hour), and cannot be revoked. If you want to prevent them from posting in the meantime, you'll also want to keep a list of blacklisted/blocked UIDs somewhere, and check against that list before allowing them to write/access the data.

You will not be able to programmatically disable a user from the frontend of your app. You will need a backend, and use the Firebase Admin SDK to update the user account to bee disabled. The API is updateUser.

Well they can always register again (in case the website is public/ not invite-only), with pletely different credentials.

You can do a matching of the new data and existing blocked users, and if it matches above a threshold, flag them.

And you can improve your reporting, the faster you detect a user who should be blocked, the better.

Can't say I'm super familiar with Firebase but ill try and help (can't hurt).

Have you tried to blacklist the IP of the user in question?

Hope I helped :)

Have a good day!

发布评论

评论列表(0)

  1. 暂无评论