homemanager-be/src/app-user/app-user.service.ts

26 lines
758 B
TypeScript

import { UserService } from 'src/objects/user/user.service';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { UserLoginResponseDto } from './dto/user-login-response.dto';
import { AuthService } from 'src/shared/auth/auth.service';
import { User } from 'src/objects/user/user.entity';
@Injectable()
export class AppUserService {
constructor(
private readonly userService: UserService,
private readonly config: ConfigService,
private readonly auth: AuthService,
) {}
async login(user: User) {
const token = await this.auth.issueJWT(user);
return new UserLoginResponseDto({
access_token: token,
expires_in: this.auth.expiry,
token_type: 'Bearer',
});
}
}