|
|
|
@ -23,7 +23,7 @@ export class AdminPasswordRecoveryService {
@@ -23,7 +23,7 @@ export class AdminPasswordRecoveryService {
|
|
|
|
|
const user = await this.usersService.getOneByPhoneNumber(phoneNumber) |
|
|
|
|
|
|
|
|
|
if (!user || user.status === Users.Status.Deleted || user.status === Users.Status.Blocked) { |
|
|
|
|
await this.sessionsService.addAuthAttemption(ip) |
|
|
|
|
await this.sessionsService.addAuthAttemption(ip, { userId: user ? user.id : null }) |
|
|
|
|
throw new InvalidCredentialsException() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -36,12 +36,13 @@ export class AdminPasswordRecoveryService {
@@ -36,12 +36,13 @@ export class AdminPasswordRecoveryService {
|
|
|
|
|
public async confirmRecovery(ip: string, dto: ConfirmPasswordRecoveryDto) { |
|
|
|
|
const isCorrect = await this.confirmationCodesService.confirmCode(dto.phoneNumber, dto.code) |
|
|
|
|
|
|
|
|
|
const user = await this.usersService.getOneByPhoneNumber(dto.phoneNumber) |
|
|
|
|
|
|
|
|
|
if (!isCorrect) { |
|
|
|
|
this.sessionsService.addAuthAttemption(ip) |
|
|
|
|
this.sessionsService.addAuthAttemption(ip, { userId: user ? user.id : null }) |
|
|
|
|
throw new WrongCodeException() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const user = await this.usersService.getOneByPhoneNumber(dto.phoneNumber) |
|
|
|
|
await this.usersService.changeUserPassword(user.id, dto.newPassword) |
|
|
|
|
|
|
|
|
|
const session = await this.sessionsService.start({ |
|
|
|
|