diff --git a/innungsapp/apps/admin/app/superadmin/actions.ts b/innungsapp/apps/admin/app/superadmin/actions.ts index 334e8f2..4bcaac4 100644 --- a/innungsapp/apps/admin/app/superadmin/actions.ts +++ b/innungsapp/apps/admin/app/superadmin/actions.ts @@ -1,7 +1,7 @@ 'use server' import { prisma } from '@innungsapp/shared' -import { auth, getSanitizedHeaders } from '@/lib/auth' +import { auth } from '@/lib/auth' import { revalidatePath } from 'next/cache' import { redirect } from 'next/navigation' import { headers } from 'next/headers' @@ -16,23 +16,9 @@ function normalizeEmail(email: string | null | undefined): string { /** * Sets a credential (email+password) account for a user. - * Tries auth.api.updateUser first (uses better-auth's internal hashing, guaranteed compatible). - * Falls back to direct DB write if that fails. + * Uses direct DB write with better-auth's hashPassword for compatibility. */ async function setCredentialPassword(userId: string, password: string) { - // Primary: use better-auth's own API to ensure correct hash format - try { - const authHeaders = await getSanitizedHeaders() - await auth.api.updateUser({ - body: { userId, password }, - headers: authHeaders, - }) - return - } catch (e) { - console.error('[setCredentialPassword] auth.api.updateUser failed, falling back to direct write:', e) - } - - // Fallback: write directly with better-auth compatible hash const hashedPassword = await hashPassword(password) const updated = await prisma.account.updateMany({ where: { userId, providerId: 'credential' },