From 223fae10e245d94965fd46fdff139f93e3c4b799 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Sep 2018 23:47:08 -0600 Subject: [PATCH] Update ProfileController --- app/Http/Controllers/ProfileController.php | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 2b9deb6b..f696c959 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -86,7 +86,7 @@ class ProfileController extends Controller } $user = Auth::user()->profile; - if($user->id == $profile->id) { + if($user->id == $profile->id || !$profile->is_private) { return false; } @@ -124,7 +124,14 @@ class ProfileController extends Controller public function showAtomFeed(Request $request, $user) { - $profile = Profile::whereUsername($user)->firstOrFail(); + $profile = $user = Profile::whereUsername($user)->firstOrFail(); + if($profile->is_private || Auth::check()) { + $blocked = $this->blockedProfileCheck($profile); + $check = $this->privateProfileCheck($profile, null); + if($check || $blocked) { + return view('profile.private', compact('user')); + } + } $items = $profile->statuses()->orderBy('created_at', 'desc')->take(10)->get(); return response()->view('atom.user', compact('profile', 'items')) ->header('Content-Type', 'application/atom+xml'); @@ -134,6 +141,13 @@ class ProfileController extends Controller { $profile = $user = Profile::whereUsername($username)->firstOrFail(); // TODO: fix $profile/$user mismatch in profile & follower templates + if($profile->is_private || Auth::check()) { + $blocked = $this->blockedProfileCheck($profile); + $check = $this->privateProfileCheck($profile, null); + if($check || $blocked) { + return view('profile.private', compact('user')); + } + } $owner = Auth::check() && Auth::id() === $user->user_id; $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; $followers = $profile->followers()->orderBy('created_at', 'desc')->simplePaginate(12); @@ -149,8 +163,15 @@ class ProfileController extends Controller public function following(Request $request, $username) { - $profile = Profile::whereUsername($username)->firstOrFail(); + $profile = $user = Profile::whereUsername($username)->firstOrFail(); // TODO: fix $profile/$user mismatch in profile & follower templates + if($profile->is_private || Auth::check()) { + $blocked = $this->blockedProfileCheck($profile); + $check = $this->privateProfileCheck($profile, null); + if($check || $blocked) { + return view('profile.private', compact('user')); + } + } $user = $profile; $owner = Auth::check() && Auth::id() === $user->user_id; $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;