fix: grant admin role to anonymous user and add DEFAULT_TOOL_VIEW env var

When AUTH_ENABLED=false, the anonymous user was assigned the "user" role
which lacks settings:write permission, making all settings saves return
403. Since no admin exists when auth is disabled, settings were
permanently read-only. Promote the anonymous user to "admin" so the
single user has full control of the instance.

Also adds DEFAULT_TOOL_VIEW env var (sidebar|fullscreen) following the
existing DEFAULT_THEME pattern, seeded via ensureDefaultSettings() on
first boot.

Closes #135
This commit is contained in:
SnapOtter
2026-05-16 11:37:28 +08:00
parent 2c45a3a9e8
commit f86ef124c2
8 changed files with 151 additions and 6 deletions
+12 -3
View File
@@ -18,12 +18,21 @@ interface AuthState {
hasLocalPassword: boolean;
}
const USER_PERMISSIONS = [
const ANON_ADMIN_PERMISSIONS = [
"tools:use",
"files:own",
"files:all",
"apikeys:own",
"apikeys:all",
"pipelines:own",
"pipelines:all",
"settings:read",
"settings:write",
"users:manage",
"teams:manage",
"features:manage",
"system:health",
"audit:read",
];
export function useAuth() {
@@ -58,8 +67,8 @@ export function useAuth() {
authEnabled: false,
isAuthenticated: true,
mustChangePassword: false,
role: "user",
permissions: USER_PERMISSIONS,
role: "admin",
permissions: ANON_ADMIN_PERMISSIONS,
analyticsEnabled: null,
analyticsConsentShownAt: null,
analyticsConsentRemindAt: null,