Files
event-qr/src/auth/auth.service.ts
2025-11-29 12:26:58 +01:00

22 lines
638 B
TypeScript

import { Injectable, UnauthorizedException } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class AuthService {
constructor(
private jwtService: JwtService,
private configService: ConfigService,
) {}
async login(password: string) {
const envPassword = this.configService.get<string>('PASSWORD');
if (password !== envPassword) {
throw new UnauthorizedException('Incorrect password');
}
const payload = { username: 'admin', sub: 'admin' };
return {
accessToken: this.jwtService.sign(payload),
};
}
}