
So i am trying to make a different layout for admins and regular users, and couldnt find a way to get the user role. I tried looking on the internet but so far i only found people addressing different roles thru permissions api. Is there any simpler way to just get the role? I know this sounds like a trivial question but thanks anyway 😄
TypeScript
try {
const currentAccount = await account.get();
if (!currentAccount) throw Error;
const currentUser = await databases.listDocuments(
databaseId,
userCollectionId,
[Query.equal('accountId', currentAccount.$id)]
)
console.log('account.get(): ', currentUser)
if (!currentUser) throw Error;
return currentUser.documents[0]
} catch (error) {
console.error(error);
}
}
}```
TL;DR
Developers are looking for a way to fetch user role labels from auth for different layouts. They are trying to distinguish between admins and regular users. The code snippet provided attempts to fetch the current user, but there is no explicit reference to obtaining the user role. One suggestion could be to store the role in the user document data upon authentication to easily access and differentiate roles for UI customization.Recommended threads
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- Pending upload some file, but not for ot...
When upload this file, always got pending. But when I upload another file, it works. Why?
- Need help setting up this error is showi...
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. If you're the app developer, register the redirect URI in the Google Cl...
