fix architecture and write new tests

This commit is contained in:
root
2026-06-10 00:40:19 -04:00
parent 560da1cadf
commit 80a597bc10
377 changed files with 84020 additions and 1337 deletions
+5 -19
View File
@@ -1,8 +1,6 @@
import bcrypt from 'bcryptjs'
import jwt from 'jsonwebtoken'
import { prisma } from '../../lib/prisma'
const JWT_SECRET = process.env.JWT_SECRET ?? 'test-secret'
import { signActorToken } from '../../security/tokens'
let counter = 0
function uid() {
@@ -215,28 +213,16 @@ export async function createRenterNotification(
})
}
export function signEmployeeToken(employeeId: string, companyId: string, role: string = 'OWNER') {
return jwt.sign(
{ sub: employeeId, companyId, role, type: 'employee' },
JWT_SECRET,
{ expiresIn: '1h' },
)
export function signEmployeeToken(employeeId: string, _companyId: string, _role: string = 'OWNER') {
return signActorToken(employeeId, 'employee', { expiresIn: '1h' })
}
export function signAdminToken(adminId: string) {
return jwt.sign(
{ sub: adminId, type: 'admin' },
JWT_SECRET,
{ expiresIn: '1h' },
)
return signActorToken(adminId, 'admin', { expiresIn: '1h', last2faAt: Date.now() })
}
export function signRenterToken(renterId: string) {
return jwt.sign(
{ sub: renterId, type: 'renter' },
JWT_SECRET,
{ expiresIn: '1h' },
)
return signActorToken(renterId, 'renter', { expiresIn: '1h' })
}
export function authHeader(token: string) {