示例#1
0
 public bool InsertUser(PureUser Username)
 {
     try
     {
         _db.Insert(Username);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#2
0
        public ActionResult Reset_password(UserLogin User, int?Id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            string ErrorMsg   = "";
            string MethodName = Constants.AuditActionType.PasswordChanged.ToString();
            var    editUser   = new PureUser();

            editUser.Userid   = Id.GetValueOrDefault();
            editUser.Password = User.Password;

            if (User.Password.Any("!@#$%^&*".Contains) && User.Password.Length >= 6)
            {
                if (User.Password == User.ConfirmPassword)
                {
                    var ExtDetails = _userMgt.getUserById(editUser.Userid);
                    editUser.Password = _userMgt.EncryptPassword(editUser.Password);
                    if (ExtDetails.Password != editUser.Password)
                    {
                        try
                        {
                            editUser.Userid = Convert.ToInt32(Id);
                            bool validatePassword = _userMgt.UpdatePassword(editUser.Password, Id);
                            if (validatePassword == true)
                            {
                                Log.InfoFormat(MethodName, ErrorMsg);
                                InsertAudit(Constants.AuditActionType.PasswordChanged, editUser.Username + "Changed password", ExtDetails.Username);
                                TempData["SuccessMsg"] = "Kindly login with the new password";
                            }

                            return(RedirectToAction("login"));
                        }
                        catch (Exception ex)
                        {
                            Log.InfoFormat(MethodName, ex.Message);
                            ViewBag.ErrorMsg = ex.Message;
                            return(View());
                        }
                    }
                    else
                    {
                        Log.InfoFormat(MethodName, ErrorMsg);
                        ViewBag.ErrorMsg = "The new password must not match the old password";
                        return(View());
                    }
                }
                else
                {
                    Log.InfoFormat(MethodName, "The confirm password must match the new password");
                    ViewBag.ErrorMsg = "The confirm password must match the new password";
                    return(View());
                }
            }
            else
            {
                ViewBag.ErrorMsg = "The password must contain special and minimum of six characters";
                return(View());
            }
        }