feat: logins and toggleable admin mode #45

Merged
gk1623 merged 2 commits from logins into master 2025-06-12 14:46:22 +00:00
14 changed files with 739 additions and 446 deletions
Showing only changes of commit 788007c1cc - Show all commits

22
src/lib/database.d.ts vendored
View File

@@ -140,6 +140,27 @@ export type Database = {
} }
Relationships: [] Relationships: []
} }
users: {
Row: {
created_at: string
id: string
is_admin: boolean
updated_at: string
}
Insert: {
created_at?: string
id: string
is_admin?: boolean
updated_at?: string
}
Update: {
created_at?: string
id?: string
is_admin?: boolean
updated_at?: string
}
Relationships: []
}
} }
Views: { Views: {
[_ in never]: never [_ in never]: never
@@ -269,4 +290,3 @@ export const Constants = {
Enums: {}, Enums: {},
}, },
} as const } as const

View File

@@ -23,6 +23,7 @@ export const load: LayoutServerLoad = async ({
} }
return { return {
session, session,
adminMode,
cookies: cookies.getAll() cookies: cookies.getAll()
}; };
}; };

View File

@@ -40,5 +40,5 @@ export const load: LayoutLoad = async ({ data, depends, fetch }) => {
data: { user } data: { user }
} = await supabase.auth.getUser(); } = await supabase.auth.getUser();
return { session, supabase, user }; return { session, supabase, user, adminMode: data.adminMode };
}; };

View File

@@ -2,7 +2,7 @@ CREATE TABLE users (
id uuid PRIMARY KEY REFERENCES auth.users ON DELETE CASCADE, id uuid PRIMARY KEY REFERENCES auth.users ON DELETE CASCADE,
is_admin boolean NOT NULL DEFAULT false, is_admin boolean NOT NULL DEFAULT false,
created_at timestamp with time zone NOT NULL DEFAULT now(), created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone NOT NULL DEFAULT now(), updated_at timestamp with time zone NOT NULL DEFAULT now()
); );
CREATE TRIGGER users_handle_updated_at CREATE TRIGGER users_handle_updated_at