Skip to content

Commit

Permalink
Fix critical issue with user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Dec 14, 2014
1 parent 115c71e commit 8f118a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions app/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public function getProfile($userName)
{
$user = $this->users->requireByName($userName);

// Make sure that the user which is updated is the one who is currently logged in.
if (Auth::user()->id !== $user->id) {
App::abort(403);
}

$threads = $user->getLatestThreadsPaginated(5);
$replies = $user->getLatestRepliesPaginated(5);

Expand All @@ -45,13 +40,23 @@ public function getSettings($userName)
{
$user = $this->users->requireByName($userName);

// Make sure that the user which is updated is the one who is currently logged in.
if (Auth::user()->id !== $user->id) {
App::abort(403);
}

$this->view('users.settings', compact('user'));
}

public function putSettings($userName)
{
$user = $this->users->requireByName($userName);

// Make sure that the user which is updated is the one who is currently logged in.
if (Auth::user()->id !== $user->id) {
App::abort(403);
}

return $this->updater->update($this, $user, Input::only('email'));
}

Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h1>{{ $user->name }}</h1>
<p><a class="button" target="_blank" href="{{ $user->github_url }}">Visit GitHub Profile</a></p>

@if (Auth::check())
@if (Auth::check() && Auth::user()->email === $user->email)
<p><a class="button" href="{{ route('user.settings', $user->name) }}">Edit Account Settings</a></p>
@endif
</div>

0 comments on commit 8f118a0

Please sign in to comment.