mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
Adds password reauthentication to our existing reauth providers, additionally swaps from an exclusive provider to an inclusive type where multiple methods can be selected to offer a this or that experience.
21 lines
437 B
TypeScript
21 lines
437 B
TypeScript
import { compare } from '@node-rs/bcrypt';
|
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
type VerifyPasswordOptions = {
|
|
userId: number;
|
|
password: string;
|
|
};
|
|
|
|
export const verifyPassword = async ({ userId, password }: VerifyPasswordOptions) => {
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: userId },
|
|
});
|
|
|
|
if (!user || !user.password) {
|
|
return false;
|
|
}
|
|
|
|
return await compare(password, user.password);
|
|
};
|