- Separate admin identity from role: viewer|model + is_admin boolean flag - DB migration 0001_is_admin: adds column, migrates former admin role users - Update ACL helpers, auth session, GraphQL types and all resolvers - Admin layout guard and header links check is_admin instead of role - Admin users table: show Admin badge next to name, remove admin from role select - Admin user edit page: is_admin checkbox toggle - Install shadcn Badge component; use in admin users table - Fix duplicate photo keys in adminGetUser resolver - Replace confirm() in /me recordings with Dialog component Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
833 B
TypeScript
30 lines
833 B
TypeScript
import Redis from "ioredis";
|
|
|
|
export type SessionUser = {
|
|
id: string;
|
|
email: string;
|
|
role: "model" | "viewer";
|
|
is_admin: boolean;
|
|
first_name: string | null;
|
|
last_name: string | null;
|
|
artist_name: string | null;
|
|
slug: string | null;
|
|
avatar: string | null;
|
|
};
|
|
|
|
export const redis = new Redis(process.env.REDIS_URL || "redis://localhost:6379");
|
|
|
|
export async function setSession(token: string, user: SessionUser): Promise<void> {
|
|
await redis.set(`session:${token}`, JSON.stringify(user), "EX", 86400);
|
|
}
|
|
|
|
export async function getSession(token: string): Promise<SessionUser | null> {
|
|
const data = await redis.get(`session:${token}`);
|
|
if (!data) return null;
|
|
return JSON.parse(data) as SessionUser;
|
|
}
|
|
|
|
export async function deleteSession(token: string): Promise<void> {
|
|
await redis.del(`session:${token}`);
|
|
}
|