Example #1
0
 public virtual ActionResult Edit(UserViewModel userViewModel)
 {
     this.Validate(userViewModel, string.Empty);
     if (!ModelState.IsValid)
         return View(userViewModel);
     var user = userRepository.GetUser(userViewModel.Username);
     Mapper.Map<UserViewModel, User>(userViewModel, user);
     return RedirectToAction(MVC.Users.List());
 }
Example #2
0
 public virtual ActionResult Create(UserViewModel userViewModel)
 {
     this.Validate(userViewModel, string.Empty);
     userViewModel.Username = SecurityController.CleanUpUsername(userViewModel.Username);
     if (ModelState.IsValid && userRepository.GetUser(userViewModel.Username) != null)
         ModelState.AddModelError("username", "Username must be unique.");
     if (!ModelState.IsValid)
         return View(userViewModel);
     userRepository.CreateUser(userViewModel.Username, userViewModel.FirstName, userViewModel.LastName, userViewModel.DisplayName, userViewModel.Title, userViewModel.RateGroup, Crypto.Hash(userViewModel.Password, Crypto.HashAlgorithm.SHA256), userViewModel.Email);
     return RedirectToAction(MVC.Users.List());
 }
Example #3
0
 public virtual ActionResult ChangePassword(UserViewModel userViewModel)
 {
     var user = userRepository.GetUser(userViewModel.Username);
     if (string.IsNullOrWhiteSpace(userViewModel.Password))
     {
         return RedirectToAction(MVC.Users.ChangePassword(userViewModel.Username));
     }
     user.PasswordHash = Crypto.Hash(userViewModel.Password, Crypto.HashAlgorithm.SHA256);
     return RedirectToAction(MVC.Users.List());
 }