trips) adding package-tours option
This commit is contained in:
12
src/lib/server/admin/auth.ts
Normal file
12
src/lib/server/admin/auth.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
export function requireAdmin(userId: string | undefined): void {
|
||||
if (!userId) throw new Error('Not authenticated');
|
||||
const adminIds = (env.ADMIN_USER_IDS ?? '')
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
if (adminIds.length === 0 || !adminIds.includes(userId)) {
|
||||
throw new Error('Admin access required');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user