From 1f46b3a85dbbf9b03f5056b3163763277fd745c9 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Thu, 28 Sep 2017 23:18:38 +0100 Subject: [PATCH] Check if user exists before checking redirect --- app/Http/Controllers/ArtistsController.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ArtistsController.php b/app/Http/Controllers/ArtistsController.php index aaae02e8..31f1325e 100644 --- a/app/Http/Controllers/ArtistsController.php +++ b/app/Http/Controllers/ArtistsController.php @@ -46,19 +46,23 @@ class ArtistsController extends Controller { $user = User::whereSlug($slug)->first(); - if ($user->redirect_to) { - $newUser = User::find($user->redirect_to); + if ($user) { + if ($user->redirect_to) { + $newUser = User::find($user->redirect_to); - if ($newUser) { - return Redirect::action('ArtistsController@getProfile', [$newUser->slug]); + if ($newUser) { + return Redirect::action('ArtistsController@getProfile', [$newUser->slug]); + } } - } - if ($user->disabled_at) { + if ($user->disabled_at) { + App::abort('404'); + } + + return View::make('artists.profile'); + } else { App::abort('404'); } - - return View::make('artists.profile'); } public function getShortlink($id)