public ActionResult ForgotPassword(SMR.KM.Business.Models.User userForgot) { try { _log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); if (!string.IsNullOrEmpty(userForgot.UserName)) { var user = _userServices.GetUser(userForgot.UserName); if (user != null) { if (user.IsAnonymous == false) { throw new Exception("You are registered as an active directory user. Please use your window credentials to logon."); } else { string decryptedPwd = KMEncryptDecrypt.Decrypt(user.Password, SiteConfig.KMEncryptDecryptKey); EmailServices oEmailServices = new EmailServices(); bool isSucess = oEmailServices.ForgotPasswordEmail(user, decryptedPwd); if (isSucess) { throw new Exception("Please check your mailbox for password."); } } } else { throw new Exception("Specified user does not exist."); } } else { throw new Exception("Username is required."); } return(View()); } catch (Exception ex) { if (_log.IsErrorEnabled) { _log.Error(ex.Message, ex); } throw ex; } }
public ActionResult Edit(SMR.KM.Business.Models.User user, string initialChar) { try { if (_log.IsInfoEnabled) { _log.Info("Calling EditUser method of UserService."); } if (ModelState.IsValid) { string hashedPassword = user.PasswordCheck == user.Password ? user.Password : KMEncryptDecrypt.Encrypt(user.Password, SiteConfig.KMEncryptDecryptKey); if (user.IsAnonymous == false) { user.IsAnonymous = true; } else { user.IsAnonymous = false; } user.Password = hashedPassword; _userServices.EditUser(user, CurrentUser); user.Plants = _userServices.GetPlant(); user.UserGroups = _userServices.GetUserGroups(); ViewBag.InitialChar = initialChar; return(RedirectToAction("Details", "User", new { id = user.UserId, userName = initialChar })); } } catch (Exception ex) { if (_log.IsErrorEnabled) { _log.Error(ex.Message, ex); } throw ex; } user.Plants = _userServices.GetPlant(); user.UserGroups = _userServices.GetUserGroups(); return(View(user)); }