Exemple #1
0
        public ActionResult ResetPassword(FormCollection form, LoanViewModel lvm, DataAccessLayerT.DataManager.User users)
        {
            try
            {
                if (users.PaswordVal != "")
                {
                    string value     = Convert.ToString(form["value"]);
                    string password  = users.PaswordVal;
                    string rpassword = Convert.ToString(form["rpassword"]);

                    if (password != rpassword)
                    {
                        TempData["ErrMsg"] = "Password Does Not Match";
                        return(View(users));
                    }
                    //string rpassword = lvm.AccountsModel.confirmPassword;

                    ResetPasswords(value, users);
                }
                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemple #2
0
        public void ResetPasswords(string value, DataAccessLayerT.DataManager.User users)
        {
            try
            {
                // if (Request.QueryString["value"] != null)
                if (value != "")
                {
                    // value = Request.QueryString["value"];
                    var result = _DR.checkValue(value);

                    if (result != null)
                    {
                        DateTime dtCreate = result.LastUpdated.Value;
                        DateTime dtNow    = MyUtility.getCurrentLocalDateTime();
                        DateTime dtExp    = dtCreate.AddMinutes(15);
                        if (dtNow > dtExp)
                        {
                            TempData["ErrMsg"] = "Password Reset Link Expired";
                        }
                        else
                        {
                            var user = _DR.getUsers(value.Trim());
                            users.ID = user.ID;

                            UpdatePassword(users);
                        }
                    }
                    else
                    {
                        var id = _DR.getUsers(value);
                        TempData["ErrMsg"] = "Invalid key please try again.";
                        return;
                    }
                }

                else
                {
                    TempData["ErrMsg"] = "Invalid Url";
                    return;
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
                WebLog.Log(ex.Message.ToString());
            }
        }
Exemple #3
0
        public ActionResult changePassword(DataAccessLayerT.DataManager.User user, FormCollection form)
        {
            try
            {
                TempData["SucMsg"] = "";
                TempData["ErrMsg"] = "";
                user.PaswordVal    = Convert.ToString(form["passwordVal"]);
                var  rpassword   = Convert.ToString(form["rpasswordVal"]);
                bool validatepas = ValidatePassword(user.PaswordVal, rpassword);
                if (validatepas == false)
                {
                    TempData["ErrMsg"] = "Password And Confirm Password Must Match";
                    return(View());
                }
                if (validatepas == true)
                {
                    var val = _DR.checkEmail(user.EmailAddress);
                    if (val == null)
                    {
                        TempData["ErrMsg"] = "User Does Not Exist";

                        return(View());
                    }
                    else
                    {
                        var EncrypPassword = new HelperClasses.CryptographyManager().ComputeHash(user.PaswordVal, HashName.SHA256);
                        user.PaswordVal = EncrypPassword;
                        _DM.changePassword(user);
                        WebLog.Log("users.Email 2" + user.EmailAddress);
                        Session["id"] = LoggedInEmail(user.EmailAddress);
                        string email       = Convert.ToString(Session["id"]);
                        string InstFkEmail = _DR.getInstFKByEmail(email);
                        Session["InstFkEmail"] = InstFkEmail;
                        Session["User"]        = Session["id"];

                        return(RedirectToAction("index", "Admin"));
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemple #4
0
 public ActionResult changePassword(DataAccessLayerT.DataManager.User user)
 {
     try
     {
         TempData["SucMsg"] = "";
         TempData["ErrMsg"] = "";
         if (user.EmailAddress == null)
         {
             return(RedirectToAction("Signin"));
         }
         var email = user.EmailAddress;
         return(View(user));
     }
     catch (Exception ex)
     {
         WebLog.Log(ex.Message.ToString());
         return(null);
     }
 }
Exemple #5
0
 public void UpdatePassword(DataAccessLayerT.DataManager.User users)
 {
     try
     {
         // LoanViewModel lvm = new LoanViewModel();
         // users.PaswordVal = lvm.AccountsModel.pasword;
         // users.confirmPassword = lvm.AccountsModel.confirmPassword;
         var EncrypPassword = new HelperClasses.CryptographyManager().ComputeHash(users.PaswordVal, HashName.SHA256);
         users.PaswordVal = EncrypPassword;
         string value = "";
         users.Audit = value;
         _DM.UpdatePassword(users);
         TempData["SucMsg"] = "Password Successfully Update.";
     }
     catch (Exception ex)
     {
         //Response.Write(ex.Message.ToString());
         WebLog.Log(ex.Message.ToString());
     }
 }
Exemple #6
0
        public void sendLink(String Email)
        {
            try
            {
                //LoanViewModel lvm = new LoanViewModel();
                //String email = lvm.AccountsModel.Email;
                User users  = new DataAccessLayerT.DataManager.User();
                var  result = _DR.checkEmail(Email);
                WebLog.Log("Email +" + result);
                if (result != null)
                {
                    WebLog.Log("Email +" + result);
                    users.EmailAddress = result;
                    WebLog.Log("Email +" + users.EmailAddress);
                    users.ID = _DR.selectUserIDs(users);
                    WebLog.Log("Email +" + users.ID);
                    if (users.ID != 0)
                    {
                        string encrypt = "";
                        try
                        {
                            encrypt = $"tK_{ Classes.Utility.RandomString(30).ToUpper()}" + users.ID;
                            users   = _DR.getUser(Email);
                            WebLog.Log("users +" + users.EmailAddress);
                            string resetLink = ConfigurationManager.AppSettings["ResetPasswordLink"] + encrypt;
                            WebLog.Log("resetLink +" + resetLink);
                            string resetLink1 = "Click The Following Link:<a href='" + resetLink + "'>'" + resetLink + "'</a> to change your password";
                            WebLog.Log("resetLink1 +" + resetLink1);
                            WebLog.Log("resetLink: " + resetLink);
                            var bodyTxt = System.IO.File.ReadAllText(Server.MapPath("~/EmailNotifications/ResetPasswordEmailNotification.html"));
                            bodyTxt = bodyTxt.Replace("$MerchantName", $"{users.Firstname} {users.Lastname}");
                            bodyTxt = bodyTxt.Replace("$Message", $"{resetLink1}");
                            var msgHeader = $"Reset Your Password";
                            WebLog.Log("resetLink: " + resetLink);

                            WebLog.Log("bodyTxt:" + bodyTxt);

                            var sendMail = NotificationService.SendMail(msgHeader, bodyTxt, users.EmailAddress, null, null);
                            //users.ResetPassword = encrypt;
                            users.Audit = encrypt;
                            // users.DateTim = MyUtility.getCurrentLocalDateTime();

                            users.LastUpdated = MyUtility.getCurrentLocalDateTime();
                            _DM.UpdateUsers(users);
                            TempData["message"] = "Please Check Your Email For Password Reset Link";
                        }
                        catch (Exception ex)
                        {
                            ex.Message.ToString();
                            WebLog.Log(ex.Message.ToString());
                        }
                    }
                    else
                    {
                        TempData["message"] = "Please Try Again";
                    }
                }
                else
                {
                    TempData["message"] = "Account Does Not Exist";
                }
            }
            catch (Exception ex)
            {
                //Response.Write(ex.Message.ToString());
                WebLog.Log(ex.Message.ToString());
            }
        }