22 lines
517 B
TypeScript
22 lines
517 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 ?? "";
|
|
|
|
console.log("Username: ", username);
|
|
console.log("Password: ", password);
|
|
|
|
console.log(user);
|
|
|
|
const res = await Bun.password.verify(password, password_hash, "bcrypt");
|
|
console.log("hash res:", res);
|
|
|
|
return res ? user : null;
|
|
}
|
|
|
|
|