mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 13:53:45 +02:00
Fix username validation and auto-generation, closes #927
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Pterodactyl\Models;
|
||||
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Sofa\Eloquence\Validable;
|
||||
use Pterodactyl\Rules\Username;
|
||||
use Illuminate\Validation\Rules\In;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -151,7 +152,7 @@ class User extends Model implements
|
||||
'uuid' => 'string|size:36|unique:users,uuid',
|
||||
'email' => 'email|unique:users,email',
|
||||
'external_id' => 'nullable|string|max:255|unique:users,external_id',
|
||||
'username' => 'alpha_dash|between:1,255|unique:users,username',
|
||||
'username' => 'between:1,255|unique:users,username',
|
||||
'name_first' => 'string|between:1,255',
|
||||
'name_last' => 'string|between:1,255',
|
||||
'password' => 'nullable|string',
|
||||
@@ -169,6 +170,7 @@ class User extends Model implements
|
||||
{
|
||||
$rules = self::eloquenceGatherRules();
|
||||
$rules['language'][] = new In(array_keys((new self)->getAvailableLanguages()));
|
||||
$rules['username'][] = new Username;
|
||||
|
||||
return $rules;
|
||||
}
|
||||
@@ -188,9 +190,9 @@ class User extends Model implements
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setUsernameAttribute($value)
|
||||
public function setUsernameAttribute(string $value)
|
||||
{
|
||||
$this->attributes['username'] = strtolower($value);
|
||||
$this->attributes['username'] = mb_strtolower($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user