Back

Realtime callback/event about user authentication status?

  • 0
  • Users
  • Accounts
  • Web
  • Cloud
yalondpsi
30 Sep, 2023, 04:45

Is there a Realtime event or callback that I can listen to, to monitor the user's authentication status? I'm using React as a front end.

TL;DR
The user is trying to listen to a realtime event/callback to monitor the user's authentication status in a React app. They have subscribed to the `account` channel using the provided code, but they are not receiving any console logs after 10 seconds. They ask for help in identifying what they might be doing wrong. Solution: It is suggested to listen to the `account` channel and make sure the user is logged in during the monitoring phase. The user can try using the `users.*.sessions.*` event to check for session end. All possible channels and authentication events can be found in the provided Appwrite documentation links.
darShan
30 Sep, 2023, 04:47

By Auth status, email/phone verification? If so, listen to account channel, make sure the user is logged in at this point.

yalondpsi
30 Sep, 2023, 04:48

@darShan Account channel ? I will check

safwan
30 Sep, 2023, 04:49
darShan
30 Sep, 2023, 04:49

realtime.subscribe('account') { result -> ... }

safwan
30 Sep, 2023, 04:50

As darshan mentioned, you can listen to the account channel. If you want to use it just to check whether there is a session or not, you can try using the users.*.sessions.* event.

yalondpsi
30 Sep, 2023, 04:51

Thank you very much! @darShan @darShan

safwan
30 Sep, 2023, 04:51

Feel free to message back here if you face any issues

darShan
30 Sep, 2023, 04:51

& @safwan :appwritecheers:

yalondpsi
30 Sep, 2023, 04:51

Sure thing

yalondpsi
30 Sep, 2023, 08:20

@safwan @darShan My goal is to listen to the event when session is ended. I set in appwrite console the session length to 10 seconds. To subscribe the events, I used: this.unsubscribeFromUserStatus = client.subscribe(['account', 'users.*.sessions.*'], response => { console.log('user status updated:', response); });

I don't get any console.log after 10 seconds. What am I doing wrong? Thank you

darShan
30 Sep, 2023, 08:23

I'm not sure if the event will be recd. for the user since they aren't logged in anymore. Pl. cross check with a function or a webhook to see if the event is fired on session end.

yalondpsi
30 Sep, 2023, 08:29

@darShan Ok

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