diff --git a/components/Account.php b/components/Account.php index e80369ba..c07a7406 100644 --- a/components/Account.php +++ b/components/Account.php @@ -224,9 +224,13 @@ public function onSignin() $data['login'] = trim($data['login']); - $messages = (new UserModel)->customMessages; + $validation = Validator::make( + $data, + $rules, + $this->getValidatorMessages(), + $this->getCustomAttributes() + ); - $validation = Validator::make($data, $rules, $messages); if ($validation->fails()) { throw new ValidationException($validation); } @@ -296,9 +300,13 @@ public function onRegister() unset($rules['username']); } - $messages = (new UserModel)->customMessages; + $validation = Validator::make( + $data, + $rules, + $this->getValidatorMessages(), + $this->getCustomAttributes() + ); - $validation = Validator::make($data, $rules, $messages); if ($validation->fails()) { throw new ValidationException($validation); } @@ -333,7 +341,7 @@ public function onRegister() } $intended = false; - + /* * Activation is by the admin, show message * For automatic email on account activation RainLab.Notify plugin is needed @@ -618,4 +626,26 @@ protected function isRegisterThrottled() return UserModel::isRegisterThrottled(Request::ip()); } + + /** + * getValidatorMessages + */ + protected function getValidatorMessages(): array + { + return (array) (new UserModel)->customMessages; + } + + /** + * getCustomAttributes + */ + protected function getCustomAttributes(): array + { + return [ + 'login' => $this->loginAttributeLabel(), + 'password' => Lang::get('rainlab.user::lang.account.password'), + 'email' => Lang::get('rainlab.user::lang.account.email'), + 'username' => Lang::get('rainlab.user::lang.user.username'), + 'name' => Lang::get('rainlab.user::lang.account.full_name') + ]; + } }