Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(rbac): address CodeRabbit follow-up on admin promotion and sign-in flash

Andrejc8828941ba07
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 0ce525901..b3678b2a7 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -378,6 +378,13 @@ export const auth = betterAuth({
}
},
after: async (user) => {
+ // The anonymous() plugin creates ephemeral users for guest
+ // access; never promote one to instance admin even if no
+ // real admin exists yet.
+ if ((user as { isAnonymous?: boolean }).isAnonymous) {
+ return;
+ }
+
// Promote the first user to instance admin atomically.
//
// A previous version of this code checked the user count in
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index c41eb6d64..eed600efd 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -184,7 +184,14 @@ function SignIn() {
}
};
- if (isConfigLoading || isInstanceStatusLoading) {
+ // Treat "no users yet" as still loading so the skeleton stays visible
+ // while the useEffect above redirects to /auth/sign-up. Otherwise the
+ // form briefly paints before the redirect fires.
+ if (
+ isConfigLoading ||
+ isInstanceStatusLoading ||
+ instanceStatus?.hasUsers === false
+ ) {
return (
<>
<PageTitle title={t("auth:signIn.pageTitle")} />