Added lib/password. Small tweaks.
Some checks failed
Node.js CI / build (postgresql, 18.18) (push) Has been cancelled

This commit is contained in:
Mike Cao 2025-09-13 09:40:20 -07:00
parent 9ccafc390a
commit baba06c692
6 changed files with 28 additions and 19 deletions

View file

@ -1,4 +1,3 @@
import bcrypt from 'bcryptjs';
import debug from 'debug';
import { ROLE_PERMISSIONS, ROLES, SHARE_TOKEN_HEADER } from '@/lib/constants';
import { secret } from '@/lib/crypto';
@ -9,15 +8,6 @@ import redis from '@/lib/redis';
import { getUser } from '@/queries/prisma/user';
const log = debug('umami:auth');
const SALT_ROUNDS = 10;
export function hashPassword(password: string, rounds = SALT_ROUNDS) {
return bcrypt.hashSync(password, rounds);
}
export function checkPassword(password: string, passwordHash: string) {
return bcrypt.compareSync(password, passwordHash);
}
export function getBearerToken(request: Request) {
const auth = request.headers.get('authorization');