29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { AuthenticateUserHandler } from '../auth/authenticate-user.service';
|
|
import { ResetPasswordService } from './reset-password.service';
|
|
import { ChangePasswordService } from './change-password.service';
|
|
import { AuthenticateUserCommand } from '../auth/authenticate-user.command';
|
|
|
|
|
|
|
|
@Injectable()
|
|
export class UsersService {
|
|
constructor(
|
|
private readonly authenticateUserService: AuthenticateUserHandler,
|
|
private readonly resetPasswordService: ResetPasswordService,
|
|
private readonly changePasswordService: ChangePasswordService,
|
|
) {}
|
|
|
|
async authenticate(user: { userName: string; password: string }) {
|
|
const command = new AuthenticateUserCommand(user.userName, user.password);
|
|
return this.authenticateUserService.execute(command);
|
|
}
|
|
async resetPassword(user: { document: string; email: string }) {
|
|
return this.resetPasswordService.execute(user.document, user.email);
|
|
}
|
|
|
|
async changePassword(user: { id: number; password: string; newPassword: string }) {
|
|
return this.changePasswordService.execute(user.id, user.password, user.newPassword);
|
|
}
|
|
}
|