feat: log staff sign-in and sign-out and force logout at a set time

This commit is contained in:
2026-10-19 13:34:55 +03:30
parent 3863c5e7d1
commit 8590579605
25 changed files with 588 additions and 15 deletions
+7
View File
@@ -26,6 +26,7 @@ import { SmsService } from '../common/sms.service';
import { LocalFileStorage } from '../storage/local-file.storage';
import { MembershipsService } from '../memberships/memberships.service';
import { BillingService } from '../billing/billing.service';
import { AttendanceService } from '../attendance/attendance.service';
import type { Actor } from '../common/record-scope';
import {
LoginDto,
@@ -110,6 +111,7 @@ export class AuthService {
private readonly files: LocalFileStorage,
private readonly memberships: MembershipsService,
private readonly billing: BillingService,
private readonly attendance: AttendanceService,
) {}
/**
@@ -407,6 +409,10 @@ export class AuthService {
return this.finishLogin(user.id);
}
async logout(actor: Actor) {
return this.attendance.recordLogout(actor);
}
async me(userId: string, organizationId: string, actor?: Actor): Promise<AuthUserDto> {
await this.memberships.requireActive(userId, organizationId);
const user = await this.prisma.user.findUnique({ where: { id: userId } });
@@ -727,6 +733,7 @@ export class AuthService {
where: { id: userId },
data: { lastLoginAt: new Date() },
});
await this.attendance.recordLogin(organizationId, userId, membership.role);
}
const accessToken = this.jwt.sign({
sub: userId,