This commit is contained in:
simon.franken
2026-02-18 16:08:42 +01:00
parent f5c0a0b2f7
commit 0f6e55302a
10 changed files with 29 additions and 14 deletions

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "full_name" VARCHAR(255);

View File

@@ -10,6 +10,7 @@ datasource db {
model User {
id String @id @db.VarChar(255)
username String @db.VarChar(255)
fullName String? @db.VarChar(255) @map("full_name")
email String @db.VarChar(255)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

View File

@@ -92,6 +92,7 @@ export async function getUserInfo(tokenSet: TokenSet): Promise<AuthenticatedUser
const id = String(claims.sub);
const username = String(userInfo.preferred_username || claims.preferred_username || claims.name || id);
const email = String(userInfo.email || claims.email || '');
const fullName = String(userInfo.name || claims.name || '') || null;
if (!email) {
throw new Error('Email not provided by OIDC provider');
@@ -100,6 +101,7 @@ export async function getUserInfo(tokenSet: TokenSet): Promise<AuthenticatedUser
return {
id,
username,
fullName,
email,
};
}

View File

@@ -32,11 +32,13 @@ export async function syncUser(user: AuthenticatedUser): Promise<void> {
where: { id: user.id },
update: {
username: user.username,
fullName: user.fullName,
email: user.email,
},
create: {
id: user.id,
username: user.username,
fullName: user.fullName,
email: user.email,
},
});

View File

@@ -3,6 +3,7 @@ import { Request } from 'express';
export interface AuthenticatedUser {
id: string;
username: string;
fullName: string | null;
email: string;
}