file based auth
This commit is contained in:
@@ -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 });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user