Skip to content

Commit 3a4ccf7

Browse files
committed
Trim whitespace from name input in profile update
1 parent 4c56098 commit 3a4ccf7

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

app/Livewire/Profile.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Contracts\Auth\MustVerifyEmail;
99
use Illuminate\Support\Facades\Auth;
1010
use Illuminate\Support\Facades\Session;
11+
use Illuminate\Support\Str;
1112
use Illuminate\Validation\ValidationException;
1213
use Livewire\Attributes\Computed;
1314
use Livewire\Component;
@@ -100,6 +101,8 @@ public function resendVerificationNotification(): void
100101

101102
public function updateProfileInformation(): void
102103
{
104+
$this->name = Str::trim($this->name);
105+
103106
$this->username = preg_replace('/[\s+]/', '_', strtolower($this->username));
104107

105108
$validated = $this->validate($this->profileRules($this->user->id), $this->profileRulesErrorMessage());

app/Livewire/Users/Profile.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Contracts\Auth\MustVerifyEmail;
1010
use Illuminate\Support\Facades\Auth;
1111
use Illuminate\Support\Facades\Session;
12+
use Illuminate\Support\Str;
1213
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
1314
use Laravel\Fortify\Features;
1415
use Livewire\Attributes\Computed;
@@ -98,6 +99,8 @@ public function hasUnverifiedEmail(): bool
9899

99100
public function updateProfileInformation(): void
100101
{
102+
$this->name = Str::trim($this->name);
103+
101104
$this->username = preg_replace('/[\s+]/', '_', strtolower($this->username));
102105

103106
$validated = $this->validate($this->profileRules($this->user->id), $this->profileRulesErrorMessage());

0 commit comments

Comments
 (0)