From 4d6766134e5d13d6ff7c7bb51a911ea84b637bf6 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Thu, 29 Jan 2026 15:11:23 +0100 Subject: [PATCH] move username sanitization to model and make it less strict --- app/Models/User.php | 3 ++- app/Services/Users/UserCreationService.php | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 690dd0e97b..57b42d45ae 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -198,7 +198,8 @@ protected static function booted(): void }); 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) { diff --git a/app/Services/Users/UserCreationService.php b/app/Services/Users/UserCreationService.php index 1728a491f7..53efb4933a 100644 --- a/app/Services/Users/UserCreationService.php +++ b/app/Services/Users/UserCreationService.php @@ -49,12 +49,6 @@ public function handle(array $data): User $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(),