Skip to content

Commit fb6c934

Browse files
committed
Add 404 error handling for missing users
1 parent abc32dd commit fb6c934

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

app/Livewire/Users/Profile.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,23 @@ public function mount(string $id)
5757
{
5858
$this->user = User::getUserWithSocialAccount($id)->first();
5959

60-
if ($this->user) {
61-
if ($this->user->id == Auth::user()->id) {
62-
return $this->redirectRoute('profile', navigate: true);
63-
}
60+
if (!$this->user) {
61+
abort(404);
62+
}
6463

65-
$this->name = $this->user->name;
64+
if ($this->user->id == Auth::user()->id) {
65+
return $this->redirectRoute('profile', navigate: true);
66+
}
6667

67-
$this->username = $this->user->username;
68+
$this->name = $this->user->name;
6869

69-
$this->email = $this->user->email;
70+
$this->username = $this->user->username;
7071

71-
$this->socials_google = $this->user->socialAccounts()->where('provider', 'google')->first();
72+
$this->email = $this->user->email;
7273

73-
$this->socials_github = $this->user->socialAccounts()->where('provider', 'github')->first();
74-
}
74+
$this->socials_google = $this->user->socialAccounts()->where('provider', 'google')->first();
75+
76+
$this->socials_github = $this->user->socialAccounts()->where('provider', 'github')->first();
7577

7678
$this->canManageTwoFactor = Features::canManageTwoFactorAuthentication();
7779

0 commit comments

Comments
 (0)