FEAT: reset password

This commit is contained in:
Arthur Simas
2022-05-27 18:57:05 -03:00
parent c25d2427c2
commit c920eb27b9
5 changed files with 103 additions and 20 deletions
+36
View File
@@ -13,6 +13,8 @@ import {
AuthDisableTotpMfaRequest,
AuthVerifyTotpMfaRequest,
AuthChangePasswordRequest,
AuthResetPasswordRequest,
AuthConfirmResetPasswordRequest,
} from '@victorradael/protospack';
import { AuthClientService } from 'src/clients/auth/client.service';
@@ -169,4 +171,38 @@ export class AuthController {
return response;
}
@Post('reset-password')
@HttpCode(HttpStatus.OK)
async resetPassword(@Body() body: AuthResetPasswordRequest): Promise<any> {
console.log(`/auth`, 'reset-password');
const { username } = body;
const response = await this.authClient
.resetPassword({ username })
.catch((err) => {
throw ErrorBuilder(err);
});
return response;
}
@Post('confirm-reset-password')
@HttpCode(HttpStatus.OK)
async confirmResetPassword(
@Body() body: AuthConfirmResetPasswordRequest,
): Promise<any> {
console.log(`/auth`, 'confirm-reset-password');
const { username, code, newPassword } = body;
const response = await this.authClient
.confirmResetPassword({ username, code, newPassword })
.catch((err) => {
throw ErrorBuilder(err);
});
return response;
}
}