Back

getcurrentUser error: AppwriteException: User (role: guests) missing scope (account)

  • 1
  • Web
vishalxtyagi
27 Sep, 2023, 15:57

<#1072905050399191082>

I'm getting this issue while trying to access th user by account.get()

TL;DR
The user is experiencing an error with the `getcurrentUser` function in their code. The error message indicates that the user's role is missing a required scope. Solution: The user should check their code to ensure that the necessary scopes are assigned to the role. They may need to update the role's permissions or add the missing scope.
safwan
27 Sep, 2023, 15:58

This means that there is no active session for the user

vishalxtyagi
27 Sep, 2023, 16:47

Thanks for the help it's solved now

vishalxtyagi
27 Sep, 2023, 16:51

I do have one more doubt, this is my directory in my next.js 13 application and I'm using useEffect to chekc for auth and redirection but due to which if someone tries to access protected page, the content is visible for few seconds after that useEffect redirects if not authenticated, Instead I want to show loading state from loading.tsx file of protected route until it will check authentication

safwan
27 Sep, 2023, 18:22

if I'm not wrong, loading.tsx is used when data is being fetched from the server-side. First thing I recommend is to not use SSR with next (for now)

safwan
27 Sep, 2023, 18:23

That being said, when you fetch data in the useEffect, you can have a local state [loading, setLoading] that changes based on whether all the data has been fetched, and use that to conditionally render a loading indicator.

vishalxtyagi
28 Sep, 2023, 00:56

👍 Thanks

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