I want to redirect admin to admin page and others to user page, how can I do so?
TL;DR
Solution:
To redirect admins to the admin page and others to the user page based on their labels, you can modify the code as follows:
```ts
try {
const account = account.get();
if (account.labels.includes('admin')) {
redirect('admin');
} else {
redirect('dashboard');
}
} catch (err) {
redirect('sign-in');
}
```After the user is authenticated you can check it's labels to see if they're an admin and if they are redirect them to whatever page you want.
you can do something like
TypeScript
// This is just something I created quickly so it probably won't work as is lol
try {
const account = account.get();
if(account.labels.includes('admin')) {
redirect('admin');
} else {
redirect('dashboard');
}
} catch (err) {
redirect('sign-in');
}
Recommended threads
- Domain Verification Failed - Fastly Conf...
I am trying to add my subdomain api.getmyself.app to my Custom Domain, but I keep getting the error: Domain 'getmyself.app' is owned by another customer I have...
- Data not loading at the frontend
My App that has been working for weeks, ain't loading anything at the frontend anymore. I thought maybe the API key expired but it's not the case. Users are log...
- Do I need to upgrade my Appwrite plan?
So i am making a file hosting & sharing platform (voltzy.lol) and i am expecting approx 5-8 million visit per month and over 30 million uploads per month do i n...