Back

How can i block any user in appwrite from react ?

  • 0
  • Web
Shubham
26 Aug, 2023, 12:23

How can i block any user in appwrite from react ?

TL;DR
How can I block any user in Appwrite from React? To block a user from your React admin panel, you can use the server-side Users API. Here is the documentation for usersUpdateStatus: [link]. This will allow you to update the status of a user and block them from your app. Additionally, you can use the accountUpdateStatus method from the client-side Account API. Here is the documentation: [link]. This can also be used to block a user, but make sure to add a variable that indicates the request is coming from your React app to trigger a special function. In summary, you can block a user
mzharfanw
26 Aug, 2023, 12:51

idk exactly that you mean, maybe you can block it if you add some variable that indicate request from Your react app, and make it trigger your Special function

safwan
26 Aug, 2023, 12:52
Shubham
26 Aug, 2023, 13:52

i dont want to block current logged in user , i want to block user that is doing in wrong activity in my app , from my react admin panel , how we can achieve this.?

safwan
26 Aug, 2023, 13:53
Shubham
26 Aug, 2023, 13:53

i mean , i am creating a app , and for content management and upload , i have created a custom admin panel in react, How will i block any user that is doing some inappropriate task , like i do from appwrite console.

Shubham
26 Aug, 2023, 13:55

so , i have to create function for that?

safwan
26 Aug, 2023, 14:12

yep. a simple function that takes a user's id, and calls the endpoint I mentioned

safwan
26 Aug, 2023, 14:12

Nothing too complex

mzharfanw
26 Aug, 2023, 14:16

yeah same with @safwan 's answer. you can use function variable 'APPWRITE_FUNCTION_USER_ID' to know user's id. And may active some trigger further information may u can check this out https://appwrite.io/docs/functions

safwan
26 Aug, 2023, 14:18

Just a heads up, I think the APPWRITE_FUNCTION_USER_ID variable stores the ID of the user that started the execution. So if you're going to trigger this function from your admin panel, it will hold your user ID, not the user ID of the violator. Hope that makes sense 😄

mzharfanw
26 Aug, 2023, 14:24

oh yeah. i agree with u. it only hold User's id😅 . user's role or team feature and determine can make it easier.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more