Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ public IActionResult GetAll()
[HttpGet("{id}")]
public IActionResult GetById(int id)
{
var user = _userService.GetById(id);

if (user == null) {
return NotFound();
}

// only allow admins to access other user records
var currentUserId = int.Parse(User.Identity.Name);
if (id != currentUserId && !User.IsInRole(Role.Admin)) {
return Forbid();
}

var user = _userService.GetById(id);

if (user == null) {
return NotFound();
}
return Ok(user);
}
}
Expand Down