Move username sanitization to model and make it less strict (#2150)

This commit is contained in:
Boy132
2026-02-01 00:07:26 +01:00
committed by GitHub
parent 93e81c26a9
commit a477c89025
2 changed files with 2 additions and 7 deletions

View File

@@ -198,7 +198,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
});
static::saving(function (self $user) {
$user->email = mb_strtolower($user->email);
$user->username = str($user->username)->lower()->toString();
$user->email = str($user->email)->lower()->toString();
});
static::deleting(function (self $user) {

View File

@@ -49,12 +49,6 @@ class UserCreationService
$data['username'] = str($data['email'])->before('@')->toString() . Str::random(3);
}
$data['username'] = str($data['username'])
->replace(['.', '-'], '')
->ascii()
->substr(0, 64)
->toString();
/** @var User $user */
$user = User::query()->forceCreate(array_merge($data, [
'uuid' => Uuid::uuid4()->toString(),