Skip to content

Commit 59ec112

Browse files
committed
Redirect superuser to /admin after login
1 parent 6678fcd commit 59ec112

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

components/auth/login.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ export function LoginComponent() {
3535
async function onSubmit(values: LoginInput) {
3636
try {
3737
const userData = await login(values.email, values.password);
38-
if (userData.orgs && userData.orgs.length > 0) {
38+
39+
// Check if user is superuser first
40+
if (userData.isSuperuser) {
41+
router.push("/admin");
42+
}
43+
// Otherwise check for orgs
44+
else if (userData.orgs && userData.orgs.length > 0) {
3945
router.push(`/${userData.orgs[0].nameId}`);
4046
} else {
4147
router.push("/onboarding");

contexts/auth-context.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface User {
1616
email: string;
1717
name: string;
1818
orgs: Org[];
19+
isSuperuser: boolean;
1920
}
2021

2122
interface AuthContextType {

0 commit comments

Comments
 (0)