Skip to content

Commit

Permalink
Make the Account onRegister validation pull from the user model. Rela…
Browse files Browse the repository at this point in the history
…ted: #373,
  • Loading branch information
Luke Towers committed Nov 19, 2019
1 parent bed2661 commit 7307e99
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function onSignin()
if (!array_key_exists('login', $data)) {
$data['login'] = post('username', post('email'));
}

$data['login'] = trim($data['login']);

$validation = Validator::make($data, $rules);
Expand Down Expand Up @@ -286,13 +286,15 @@ public function onRegister()
$data['password_confirmation'] = post('password');
}

$rules = (new UserModel)->rules;

$rules = [
'email' => 'required|email|between:6,255',
'password' => 'required|between:4,255|confirmed'
];

if ($this->loginAttribute() == UserSettings::LOGIN_USERNAME) {
$rules['username'] = 'required|between:2,255';
if ($this->loginAttribute() !== UserSettings::LOGIN_USERNAME) {
unset($rules['username']);
}

$validation = Validator::make($data, $rules);
Expand Down

0 comments on commit 7307e99

Please sign in to comment.