public IActionResult ModifyUser(ModifyUserModel model) { if (!AuthorizeService.AuthorizeUser(User, model.Id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { if (ModelState.IsValid) { Response response = UserService.UpdateUser(model.Id, model.Username); if (response.IsSuccessful) { return(RedirectToAction("Success")); } else { ModelState.AddModelError(string.Empty, response.Message); return(View(model)); } } else { return(View(model)); } } }
public IActionResult Modify(ModifyCurrentUserModel model) { if (!AuthorizeService.AuthorizeUser(User, model.Id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { if (ModelState.IsValid) { User user = ModelConverter.ConvertFromUserModifyCurrnetUserModel(model); Response response = UserService.UpdateUser(user); if (response.IsSuccessful) { return(RedirectToAction("Success")); } else { ModelState.AddModelError(string.Empty, response.Message); return(View(model)); } } else { return(View(model)); } } }
public IActionResult Modify(int id) { if (AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } var user = userService.GetById(id); var modifyUser = ModelConverter.ConvertToUserModifyModel(user); return(View(modifyUser)); }
public IActionResult Details(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("Auth", "AccessDenied")); } var user = UsersService.GetById(id); var viewModel = ModelConvertor.ConvertToUserDetailsModel(user); return(View(viewModel)); }
public IActionResult ChangePassword(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("Auth", "AccessDenied")); } var model = new UserChangePassModel(); model.Id = id; return(View(model)); }
public IActionResult Modify(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { ModifyCurrentUserModel model = ModelConverter.ConvertToModifyCurrentUserModel(UserService.GetById(id)); return(View(model)); } }
public IActionResult GiveAdminRole(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { UserService.GiveAdminRole(id); return(RedirectToAction("ModifyUsers")); } }
public IActionResult Details(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { User user = UserService.GetById(id); UserDetailsModel model = ModelConverter.ConvertToUserDetailsModel(user); return(View(model)); } }
public IActionResult Delete(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("Auth", "AccessDenied")); } UsersService.Delete(id); if (Convert.ToInt32(User.FindFirst("Id").Value) == id) { return(RedirectToAction("Auth", "SignOut")); } return(RedirectToAction("UserModified")); }
public IActionResult ChangePassword(UserChangePassModel userChangePassModel) { if (!AuthorizeService.AuthorizeUser(User, userChangePassModel.Id)) { return(RedirectToAction("Auth", "AccessDenied")); } if (ModelState.IsValid) { UsersService.ChangePassword(userChangePassModel.Id, userChangePassModel.Password); return(RedirectToAction("UserModified")); } return(View(userChangePassModel)); }
public IActionResult Delete(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } userService.Delete(id); if (Convert.ToInt32(User.FindFirst("Id").Value) == id) { RedirectToAction("SignOut", "Auth"); } return(RedirectToAction("SuccessfulUserChange")); }
public IActionResult Delete(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } usersService.Delete(id); logsService.Log("Delete", $"Requested for user id: {id}", Convert.ToInt32(User.FindFirst("Id").Value)); if (Convert.ToInt32(User.FindFirst("Id").Value) == id) { return(RedirectToAction("SignOut", "Auth")); } return(RedirectToAction("SuccessfulUserChange")); }
public IActionResult ChangePassword(ChangePassword model) { if (!AuthorizeService.AuthorizeUser(User, model.Id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { if (ModelState.IsValid) { UserService.ChangePassword(model.Id, model.Password); return(RedirectToAction("Success")); } else { return(View(model)); } } }
public IActionResult RemoveAdminRole(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { UserService.RemoveAdminRole(id); } if (Convert.ToInt32(User.FindFirst("Id").Value) == id) { return(RedirectToAction("SignOut", "Auth")); } else { return(RedirectToAction("ModifyUsers")); } }
public IActionResult Modify(UserModifyModel model) { if (AuthorizeService.AuthorizeUser(User, model.Id)) { return(RedirectToAction("AccessDenied", "Auth")); } if (ModelState.IsValid) { var user = ModelConverter.ConvertFromUserModifyModel(model); var result = userService.ModifyUser(user); if (result.Status) { RedirectToAction("SuccessfulUserChange"); } else { ModelState.AddModelError("", result.Message); } } return(View(model)); }