Files
zerobyte/app/server/modules/auth/helpers.ts
Nico 35773a6969 refactor: upgrade to drizzle v1 (#450)
* refactor: move migrations to new structure

* refactor: convert all findMany to new structure

* fix(backups-schedule): missing null matching for last backup status

* chore: move root lib to server
2026-02-01 19:14:52 +01:00

25 lines
569 B
TypeScript

import { verifyPassword } from "better-auth/crypto";
import { db } from "~/server/db/db";
type PasswordVerificationBody = {
userId: string;
password: string;
};
export const verifyUserPassword = async ({ password, userId }: PasswordVerificationBody) => {
const userAccount = await db.query.account.findFirst({
where: { userId },
});
if (!userAccount || !userAccount.password) {
return false;
}
const isPasswordValid = await verifyPassword({ password: password, hash: userAccount.password });
if (!isPasswordValid) {
return false;
}
return true;
};