Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Redirect to admin setup when initial admin is detected (#1861)

Luke Vella1fb44466cadb
diff --git a/apps/web/src/auth/data.ts b/apps/web/src/auth/data.ts
index fb74fe9eb..fb7175b57 100644
--- a/apps/web/src/auth/data.ts
+++ b/apps/web/src/auth/data.ts
@@ -8,6 +8,7 @@ import { createSpaceDTO } from "@/features/space/data";
import { createUserDTO } from "@/features/user/data";
import { AppError } from "@/lib/errors";
import { auth } from "@/next-auth";
+import { isInitialAdmin } from "@/utils/is-initial-admin";
export const getCurrentUser = async () => {
const session = await auth();
@@ -144,6 +145,10 @@ export const requireAdmin = cache(async () => {
const user = await requireUser();
if (user.role !== "admin") {
+ if (isInitialAdmin(user.email)) {
+ return redirect("/admin-setup");
+ }
+
notFound();
}
});