Skip to content

Commit 4bbdcf0

Browse files
authored
Ensure email is included in state (#1312)
If email is hidden for serialization (in the User model `hidden` array) the view will crash, as `toArray()` won't include the email. Hiding email field in particular is useful to avoid accidentally exposing other users emails to the frontend / client.
1 parent a08ebb8 commit 4bbdcf0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Http/Livewire/UpdateProfileInformationForm.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ class UpdateProfileInformationForm extends Component
3939
*/
4040
public function mount()
4141
{
42-
$this->state = Auth::user()->withoutRelations()->toArray();
42+
$user = Auth::user();
43+
44+
$this->state = array_merge([
45+
'email' => $user->email,
46+
], $user->withoutRelations()->toArray());
4347
}
4448

4549
/**

0 commit comments

Comments
 (0)