Manzar
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');
}
``` Kenny
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.
Kenny
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
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...