Clean validator in AccountController

This commit is contained in:
Alice Gaudon 2021-02-23 17:45:32 +01:00
parent caae753d74
commit ec0dc30709

View File

@ -91,11 +91,11 @@ export default class AccountController extends Controller {
}
protected async postChangePassword(req: Request, res: Response): Promise<void> {
const validationMap = {
await Validator.validate({
'new_password': new Validator().defined(),
'new_password_confirmation': new Validator().sameAs('new_password', req.body.new_password),
};
await Validator.validate(validationMap, req.body);
}, req.body);
const user = req.as(RequireAuthMiddleware).getUser();
const passwordComponent = user.as(UserPasswordComponent);
if (passwordComponent.hasPassword() && !await passwordComponent.verifyPassword(req.body.current_password)) {