public bool IsCurrentUsersAccount(int userId) { var user = _workoutRepository.GetUser(userId); if (user == null) { return(false); } return(GetCurrentAADObjectId() == user.AADObjectId); }
public IActionResult ViewUser(int id) { var user = _workoutRepository.GetUser(id); if (user == null) { return(RedirectToAction("index", "bdbusr")); } var model = _utilities.MapUserToUserDto(user); return(View(model)); }
public IActionResult ViewMyProfile(int id) { var user = _workoutRepository.GetUser(id); if (user == null) { return(RedirectToAction("Index", "Home")); } if (!_utilities.IsCurrentUsersAccount(user.AADObjectId)) { return(RedirectToAction("Index", "Home")); } var model = _utilities.MapUserToUserDto(user); return(View(model)); }