Merge pull request #397 from pixelfed/frontend-ui-refactor

Update RegisterController
This commit is contained in:
daniel 2018-08-20 18:35:24 -06:00 committed by GitHub
commit e90d7c52bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,11 +51,22 @@ class RegisterController extends Controller
protected function validator(array $data) protected function validator(array $data)
{ {
$this->validateUsername($data['username']); $this->validateUsername($data['username']);
$usernameRules = [
'required',
'alpha_dash',
'min:2',
'max:15',
'unique:users',
function($attribute, $value, $fail) {
if(!ctype_alpha($value[0])) {
return $fail($attribute . ' is invalid. Username must be alpha-numeric and start with a letter.');
}
}
];
$rules = [ $rules = [
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'username' => 'required|alpha_dash|min:2|max:15|unique:users', 'username' => $usernameRules,
'email' => 'required|string|email|max:255|unique:users', 'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed', 'password' => 'required|string|min:6|confirmed',
]; ];