file based auth

This commit is contained in:
2026-02-23 09:58:08 +00:00
parent 0bea406dcd
commit 2779fe22c6
40 changed files with 456 additions and 1010 deletions
+2 -5
View File
@@ -1,6 +1,6 @@
import type { User } from 'types';
import type { Handler } from 'hono';
import { officerdb, eq, Users } from 'officerdb';
import { updateUser } from 'officerdb';
import { verify } from '@@/jwt';
import argon2 from 'argon2';
import * as errors from '@@/custom-errors';
@@ -13,10 +13,7 @@ export const resetPasswordHandler: Handler = async function (ctx) {
const userInfo = (await verify(verificationCode)) as User;
if (!userInfo) throw errors.UNAUTHORIZED();
const passwordHash = await argon2.hash(password);
await officerdb
.update(Users)
.set({ password: passwordHash, status: 'Active', passwordChangedAt: now })
.where(eq(Users.id, userInfo.id));
await updateUser(userInfo.id, { password: passwordHash, status: 'Active', passwordChangedAt: now });
return ctx.json({ ok: true });
};