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('PASSWORD'); if (password !== envPassword) { throw new UnauthorizedException('Incorrect password'); } const payload = { username: 'admin', sub: 'admin' }; return { accessToken: this.jwtService.sign(payload), }; } }