Back

Some questions related to Auth

  • 0
  • Android
  • Auth
  • General
Shivam
4 Jan, 2025, 13:08

I have some questions related to Auth in Android(Kotlin) Jetpack Compose.

1:- How can I know with Account.Get() that if a user is already logged in or need to login? So that I can show the main content or Login Screen.

2:- Is Accoount.Get() always returns updated value? I mean if I change the name of a authenticated user from server, will it be immediately updated to the user device? If no, then how can I achieve this?

TL;DR
1. Save a local value for the user's login status to determine if they need to log in before showing the main content or the login screen. Check for errors like missing scope 'account' to handle invalid sessions. 2. Yes, 'Account.Get()' fetches the session from the server, ensuring that the data is always updated, even if changes are made to the authenticated user's details on the server.
D5
4 Jan, 2025, 13:59
  1. If account.get() throws an error, specifically missing scope account... That means the user is not logged in.

The most optimal approach is probably saving locally some value so the user is redirected to the login screen immediately at least first time, and then once logged in, redirect it to home screen, saving you bandwith usage and unnecesary checks. Then if there is some error, check if it's due to not having a valid session (you run account.get then)

  1. Yes, it fetches the session from the server so consequently the data will always be updated.
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