mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Fix admin password reset to use Better Auth hashing
This commit is contained in:
1 parent
31d8d53f7c
commit
6cca332e0a
1 file changed
+2
-4
@@ -3,6 +3,7 @@ import type { AuthInstance } from '../auth'
|
||||
import { Database } from 'bun:sqlite'
|
||||
import { ENV } from '@opencode-manager/shared/config/env'
|
||||
import { logger } from '../utils/logger'
|
||||
import { hashPassword } from 'better-auth/crypto'
|
||||
|
||||
export function createAuthRoutes(auth: AuthInstance, _db: Database) {
|
||||
const app = new Hono()
|
||||
@@ -38,10 +39,7 @@ export async function syncAdminFromEnv(auth: AuthInstance, db: Database): Promis
|
||||
|
||||
if (existingUser) {
|
||||
if (ENV.AUTH.ADMIN_PASSWORD_RESET) {
|
||||
const hashedPassword = await Bun.password.hash(adminPassword, {
|
||||
algorithm: 'bcrypt',
|
||||
cost: 10,
|
||||
})
|
||||
const hashedPassword = await hashPassword(adminPassword)
|
||||
db.prepare('UPDATE "account" SET password = ? WHERE "userId" = ? AND "providerId" = ?').run(
|
||||
hashedPassword,
|
||||
existingUser.id,
|
||||
|
||||
Reference in new issue
Block a user