Add basic credentials authentication

This commit is contained in:
Meier Lukas
2023-07-28 18:51:44 +02:00
parent d507f0807f
commit d7f6bdf417
11 changed files with 794 additions and 12 deletions

5
src/utils/security.ts Normal file
View File

@@ -0,0 +1,5 @@
import bcrypt from "bcrypt";
export const hashPassword = (password: string, salt: string) => {
return bcrypt.hashSync(password, salt);
};

11
src/utils/session.ts Normal file
View File

@@ -0,0 +1,11 @@
import { randomUUID } from "crypto";
export const fromDate = (seconds: number, date = Date.now()) => {
return new Date(date + seconds * 1000);
};
// Helper functions to generate unique keys and calculate the expiry dates for session cookies
export const generateSessionToken = () => {
return randomUUID();
};