13 lines
374 B
TypeScript
13 lines
374 B
TypeScript
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');
|
|
}
|
|
}
|