Clean validator in AccountController
This commit is contained in:
parent
caae753d74
commit
ec0dc30709
@ -91,11 +91,11 @@ export default class AccountController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async postChangePassword(req: Request, res: Response): Promise<void> {
|
protected async postChangePassword(req: Request, res: Response): Promise<void> {
|
||||||
const validationMap = {
|
await Validator.validate({
|
||||||
'new_password': new Validator().defined(),
|
'new_password': new Validator().defined(),
|
||||||
'new_password_confirmation': new Validator().sameAs('new_password', req.body.new_password),
|
'new_password_confirmation': new Validator().sameAs('new_password', req.body.new_password),
|
||||||
};
|
}, req.body);
|
||||||
await Validator.validate(validationMap, req.body);
|
|
||||||
const user = req.as(RequireAuthMiddleware).getUser();
|
const user = req.as(RequireAuthMiddleware).getUser();
|
||||||
const passwordComponent = user.as(UserPasswordComponent);
|
const passwordComponent = user.as(UserPasswordComponent);
|
||||||
if (passwordComponent.hasPassword() && !await passwordComponent.verifyPassword(req.body.current_password)) {
|
if (passwordComponent.hasPassword() && !await passwordComponent.verifyPassword(req.body.current_password)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user