예제 #1
0
 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));
         }
     }
 }
예제 #2
0
 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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        public IActionResult ChangePassword(int id)
        {
            if (!AuthorizeService.AuthorizeUser(User, id))
            {
                return(RedirectToAction("Auth", "AccessDenied"));
            }

            var model = new UserChangePassModel();

            model.Id = id;
            return(View(model));
        }
예제 #6
0
 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));
     }
 }
예제 #7
0
 public IActionResult GiveAdminRole(int id)
 {
     if (!AuthorizeService.AuthorizeUser(User, id))
     {
         return(RedirectToAction("AccessDenied", "Auth"));
     }
     else
     {
         UserService.GiveAdminRole(id);
         return(RedirectToAction("ModifyUsers"));
     }
 }
예제 #8
0
 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));
     }
 }
예제 #9
0
        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"));
        }
예제 #10
0
        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));
        }
예제 #11
0
        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"));
        }
예제 #12
0
        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"));
        }
예제 #13
0
 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));
         }
     }
 }
예제 #14
0
 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"));
     }
 }
예제 #15
0
        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));
        }