import { Injectable, UnauthorizedException } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';

@Injectable()
export class AuthService {
  constructor(private jwtService: JwtService) {}

  async login(loginDto: any) {
    if (loginDto.username !== 'admin' || loginDto.password !== 'P@ssw0rd2026') {
      throw new UnauthorizedException('Invalid credentials');
    }
    const payload = { username: 'admin', sub: 1 };
    return {
      access_token: this.jwtService.sign(payload),
    };
  }
}
