fix: improve oidc,fix truncate

This commit is contained in:
Théo LAGACHE
2026-02-23 16:47:01 +01:00
18 changed files with 201 additions and 191 deletions
+12 -4
View File
@@ -161,6 +161,18 @@ export const auth = betterAuth({
issuer: p.issuerUrl,
})),
provisionUser: async ({ user: usr, userInfo, provider }) => {
const existingUser = await db.query.user.findFirst({
where: eq(drizzleDb.schemas.user.email, usr.email),
});
if (existingUser && existingUser.role === "superadmin") {
return;
}
if (existingUser && env.AUTH_SYNC_OIDC_ROLES_ON_LOGIN === "false") {
return;
}
const providerId = provider.providerId;
const oidcProvider = oidcProviders.find((p) => p.id === providerId);
const allowedGroup = oidcProvider?.allowedGroup || env.ALLOWED_GROUP;
@@ -225,10 +237,6 @@ export const auth = betterAuth({
roleToAssign = "superadmin";
}
const existingUser = await db.query.user.findFirst({
where: eq(drizzleDb.schemas.user.email, usr.email),
});
if (existingUser) {
await db
.update(drizzleDb.schemas.user)