Skip to content

Commit

Permalink
Merge pull request lonnieezell#366 from MGatner/username-constraint
Browse files Browse the repository at this point in the history
Username Constraints
  • Loading branch information
lonnieezell committed Jun 8, 2021
2 parents fb0c8b8 + c72dbd1 commit 4599540
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Authentication/Passwords/ValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function buildUserFromRequest()
{
$fields = $this->prepareValidFields();

$data = service('request')->getPost($fields);
$data = array_filter(service('request')->getPost($fields));

return new User($data);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function attemptRegister()
// Validate here first, since some things,
// like the password, can only be validated properly here.
$rules = [
'username' => 'required|alpha_numeric_space|min_length[3]|is_unique[users.username]',
'username' => 'required|alpha_numeric_space|min_length[3]|max_length[30]|is_unique[users.username]',
'email' => 'required|valid_email|is_unique[users.email]',
'password' => 'required|strong_password',
'pass_confirm' => 'required|matches[password]',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UserModel extends Model

protected $validationRules = [
'email' => 'required|valid_email|is_unique[users.email,id,{id}]',
'username' => 'required|alpha_numeric_punct|min_length[3]|is_unique[users.username,id,{id}]',
'username' => 'required|alpha_numeric_punct|min_length[3]|max_length[30]|is_unique[users.username,id,{id}]',
'password_hash' => 'required',
];
protected $validationMessages = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Fakers/UserFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function fake(Generator &$faker): User
{
return new User([
'email' => $faker->email,
'username' => implode('_', $faker->words),
'username' => $faker->userName,
'password' => bin2hex(random_bytes(16)),
]);
}
Expand Down

0 comments on commit 4599540

Please sign in to comment.