Ejemplo n.º 1
0
 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;
     }
 }