FEAT: change password

This commit is contained in:
Arthur Simas
2022-05-27 18:55:43 -03:00
parent 0f13d0c590
commit c25d2427c2
5 changed files with 77 additions and 19 deletions
+25 -1
View File
@@ -5,7 +5,6 @@ import {
Post,
HttpCode,
HttpStatus,
UnauthorizedException,
} from '@nestjs/common';
import {
AuthSignInRequest,
@@ -13,6 +12,7 @@ import {
AuthEnableTotpMfaRequest,
AuthDisableTotpMfaRequest,
AuthVerifyTotpMfaRequest,
AuthChangePasswordRequest,
} from '@victorradael/protospack';
import { AuthClientService } from 'src/clients/auth/client.service';
@@ -145,4 +145,28 @@ export class AuthController {
return response;
}
@Post('change-password')
@HttpCode(HttpStatus.OK)
async changePassword(
@Body() body: AuthChangePasswordRequest,
@Headers() headers,
): Promise<any> {
console.log(`/auth`, 'change-password');
const { oldPassword, newPassword } = body;
const { authorization: accessToken } = headers;
const response = await this.authClient
.changePassword({
accessToken,
oldPassword,
newPassword,
})
.catch((err) => {
throw ErrorBuilder(err);
});
return response;
}
}