Stundenaufzeichnung/src/lib/server/auth.ts

16 lines
386 B
TypeScript

import Bun from 'bun';
import { User, get_user_by_name } from "$lib/server/database";
export async function authorize_password(username: string, password: string): Promise<User | null> {
const user = get_user_by_name(username);
const password_hash = user?.password ?? "";
const res = await Bun.password.verify(password, password_hash, "bcrypt");
return res ? user : null;
}