Exemplo n.º 1
0
        public ActionResult login(UserLogOnModel model)
        {
            if (!_validateCodeService.CheckCode(model.ValidCode))
            {
                _validateCodeService.ClearSession();
                return(Json(new { result = false, message = "验证码不正确" }, JsonRequestBehavior.AllowGet));
            }

            var userInfo = _accountInfoTask.GetAccount(model.Account);

            if (userInfo == null)
            {
                return(Json(new { result = false, message = "用户不存在" }, JsonRequestBehavior.AllowGet));
            }

            if (userInfo.Password != CryptTools.HashPassword(model.Password))
            {
                return(Json(new { result = false, message = "用户名或密码不正确" }, JsonRequestBehavior.AllowGet));
            }

            // 添加登录日志

            _accountLoginLogTask.Add(new AccountLoginLog
            {
                Account    = userInfo.Account,
                CreateDate = DateTime.Now,
                IP         = DNTRequest.GetIP(),
            });
            // 更新购物车


            FormsAuthServiceCookie.SignIn(model.Account, false);
            return(Json(new { result = true, message = string.Empty }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public ActionResult LogOn(LogOnModel model)
 {
     if (ModelState.IsValid)
     {
         var userPassword = _adminUserTask.GetByUserName(model.UserName);
         if (userPassword == null)
         {
             return(AlertMsg("账号不存在", Request.UrlReferrer.PathAndQuery));
         }
         if (userPassword.Password != CryptTools.HashPassword(model.Password))
         {
             return(AlertMsg("账号或密码不正确", Request.UrlReferrer.PathAndQuery));
         }
         if (userPassword.IsLock)
         {
             return(AlertMsg("对不起,您的账号被锁定", Request.UrlReferrer.PathAndQuery));
         }
         if (model.ValidationCode != Session["code"].ToString())
         {
             return(AlertMsg("验证码不正确", Request.UrlReferrer.PathAndQuery));
         }
         AccountDto account = new AccountDto();
         account.AdminUserId = userPassword.AdminUserId;
         account.UserName    = userPassword.UserName;
         account.RoleId      = userPassword.RoleId;
         Session["Account"]  = account;
         SysLogTask.AddLog(new MyProject.Core.Entities.SysLogDto()
         {
             Message = "", Module = LogModuleEnum.Land, Type = LogTypeEnum.Land, Operator = userPassword.UserName, Result = "登陆成功"
         });
         return(RedirectToAction("Index", "Home"));
     }
     return(View(model));
 }
Exemplo n.º 3
0
        public ActionResult LogInIndex(LogOnModel model)
        {
            if (ModelState.IsValid)
            {
                var userPassword = _adminUserTask.GetByUserName(model.UserName);
                if (userPassword == null)
                {
                    ModelState.AddModelError("UserName", "账号不存在");
                    return(View(model));
                }
                if (userPassword.Password != CryptTools.HashPassword(model.Password))
                {
                    ModelState.AddModelError("UserName", "密码不正确");
                    return(View(model));
                }
                if (userPassword.IsLock)
                {
                    ModelState.AddModelError("Password", "对不起,您的账号被锁定");
                    return(View(model));
                }

                HttpCookie cookie = new HttpCookie("Account", userPassword.UserName);
                cookie.Expires = DateTime.Now.AddMinutes(60);
                Response.Cookies.Add(cookie);

                SysLogTask.AddLog(new MyProject.Core.Entities.SysLogDto()
                {
                    Message = "", Module = LogModuleEnum.Land, Type = LogTypeEnum.Land, Operator = userPassword.UserName, Result = "登陆成功"
                });
                return(RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }
Exemplo n.º 4
0
 public ActionResult LogOn(LogOnModel model)
 {
     if (ModelState.IsValid)
     {
         var userPassword = _adminUserTask.GetByUserName(model.UserName);
         if (userPassword == null)
         {
             return(AlertMsg("账号不存在", Request.UrlReferrer.PathAndQuery));
         }
         if (userPassword.Password != CryptTools.HashPassword(model.Password))
         {
             return(AlertMsg("账号或密码不正确", Request.UrlReferrer.PathAndQuery));
         }
         if (userPassword.IsLock)
         {
             return(AlertMsg("对不起,您的账号被锁定", Request.UrlReferrer.PathAndQuery));
         }
         if (model.ValidationCode != context.Session["code"].ToString())
         {
             return(AlertMsg("验证码不正确", Request.UrlReferrer.PathAndQuery));
         }
         FormsAuthService.SignIn(userPassword.UserName, false);
         return(RedirectToAction("Index", "Home"));
     }
     return(View(model));
 }
    private void SavePwd()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";
        if (!Request.Form["NewPassword"].Trim().Equals(Request.Form["ComfirmPassword"].Trim()))
        {
            result.Msg = "新密码不一致!";
        }
        else
        {
            var id    = Convert.ToInt32(Request.Form["id"]);
            var model = userBll.Get(id);
            if (model != null)
            {
                if (model.Password == CryptTools.HashPassword(Request.Form["OldPassword"]))
                {
                    model.Password = CryptTools.HashPassword(Request.Form["ComfirmPassword"]);
                    if (userBll.Update(model))
                    {
                        result.IsSuccess = true;
                        result.Msg       = "更新成功!";
                    }
                }
                else
                {
                    result.Msg = "旧密码不正确!";
                }
            }
        }
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
Exemplo n.º 6
0
 /// <summary>
 /// 修改密码
 /// </summary> 
 public void ChangePassword(string account, string newPassword)
 {
     var userInfo = _dao.GetAccount(account);
     if (userInfo != null)
     {
         userInfo.Password = CryptTools.HashPassword(newPassword);
         _dao.Update(userInfo);
     }
 }
    private void GALogin()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "登录失败!";
        var password = Request.Form["htxtPassword"]; //登录密码改在客户用js 的DES加密
        var userName = Request.Form["txtUserName"];
        var vcode    = Request.Form["txtCode"];
        //    var remember = Request.Form["rememberme"] == "on" ? true : false;
        string ssCode = string.Empty;

        if (Session["session_verifycode"] != null)
        {
            ssCode = Session["session_verifycode"].ToString();
            Session.Remove("session_verifycode");
        }
        else
        {
            Response.Write(result.ToJsonString());
            Response.ContentType = "application/json";
            Response.End();
        }
        if (!ssCode.Equals(vcode, StringComparison.CurrentCultureIgnoreCase))
        {
            result.Msg = "验证码错误,请重新输入!";
            Response.Write(result.ToJsonString());
            Response.ContentType = "application/json";
            Response.End();
        }
        //解密的密码
        var    PPassword = DES.uncMe(password, userName);
        string msg;

        //将明文密码转化为MD5加密
        password = CryptTools.HashPassword(PPassword);
        LoginResultEnum loginResult = LoginUtil.GALogin(StringSafeFilter.Filter(userName), StringSafeFilter.Filter(password.ToUpper()), false, out msg);

        if (loginResult == LoginResultEnum.LoginSuccess)
        {
            result.IsSuccess = true;
            result.Msg       = msg;
        }

        if (loginResult == LoginResultEnum.NoUser ||
            loginResult == LoginResultEnum.OtherError || loginResult == LoginResultEnum.PasswordError ||
            loginResult == LoginResultEnum.LockUser)
        {
            result.Msg = msg;
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
Exemplo n.º 8
0
        public ActionResult Save(SaveAdminUserModel savemodel)
        {
            ViewBag.RoleList = _adminUserRoleTask.GetAll().ToSelectList(c => c.RoleId.ToString(), c => c.RoleName);
            if (savemodel.AdminUserId == null)
            {
                if (savemodel.Password != savemodel.PasswordTwo)
                {
                    ModelState.AddModelError("PasswordTwo", "密码不一致");
                    return(View(savemodel));
                }
                var user = _adminUserTask.GetByUserName(savemodel.UserName);
                if (user != null)
                {
                    ModelState.AddModelError("UserName", "用户名称已注册");
                    return(View(savemodel));
                }
                if (ModelState.IsValid)
                {
                    var model = new AdminUser
                    {
                        UserName = savemodel.UserName,
                        Password = CryptTools.HashPassword(savemodel.Password),
                        IsLock   = false,
                        RoleId   = savemodel.RoleId
                    };
                    _adminUserTask.Add(model);

                    return(CloseParentBox("保存成功", "/AdminUsers/List"));
                }
            }
            else
            {
                var model = _adminUserTask.GetById((int)savemodel.AdminUserId);

                if (model == null)
                {
                    return(AlertMsg("参数错误", HttpContext.Request.UrlReferrer.PathAndQuery));
                }

                model.RoleId = savemodel.RoleId;

                _adminUserTask.Update(model);
                return(CloseParentBox("修改成功", "/AdminUsers/List"));
            }
            return(View(savemodel));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 注册
        /// </summary> 
        public AccountInfo Register(string account, string password,string nickname, string email,string qq, string ipAddress)
        {
            var userInfo = new AccountInfo
            {
                Email = email,
                Account = account,
              
                Password = CryptTools.HashPassword(password),
                Phone = string.Empty,
                RegDate = DateTime.Now,
                RegIP = ipAddress,
                QQ = qq,
                NickName = nickname,

            };
            var userId = Convert.ToInt32(_dao.Add(userInfo));
            userInfo.ID = userId;
            return userInfo;
        }
Exemplo n.º 10
0
        public ActionResult CheckPassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                var adminusr = _adminUserTask.GetByUserName(LogOnUserName);
                if (adminusr == null)
                {
                    ModelState.AddModelError("OldPassword", "用户不存在,无法更改新密码");
                }
                if (adminusr.Password != CryptTools.HashPassword(model.OldPassword))
                {
                    ModelState.AddModelError("OldPassword", "旧密码不正确");
                }
                adminusr.Password = CryptTools.HashPassword(model.NewPassword);
                _adminUserTask.Update(adminusr);
                return(AlertMsg("", Url.Action("CheckPassword", "AdminUsers")));
            }

            return(View(model));
        }
Exemplo n.º 11
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            var name = FormsAuthService.GetCurrentIdentity().Name;
            var user = _adminUserTask.GetByUserName(name);

            if (user.Password != CryptTools.HashPassword(model.OldPw))
            {
                ModelState.AddModelError("OldPw", "旧密码不正确");
            }
            if (model.NewPw != model.AgainPw)
            {
                ModelState.AddModelError("AgainPw", "两次密码不一致");
            }
            if (ModelState.IsValid)
            {
                user.Password = CryptTools.HashPassword(model.AgainPw);
                _adminUserTask.Update(user);
                return(AlertMsg("修改成功!", "/account/index"));
            }
            return(View());
        }
Exemplo n.º 12
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            var name = GetCurrentAdmin();
            var user = _adminUserTask.GetByUserName(name);

            if (user.Password != CryptTools.HashPassword(model.OldPw))
            {
                ModelState.AddModelError("OldPw", "旧密码不正确");
            }
            if (model.NewPw != model.AgainPw)
            {
                ModelState.AddModelError("AgainPw", "两次密码不一致");
            }
            if (ModelState.IsValid)
            {
                user.Password = CryptTools.HashPassword(model.AgainPw);
                _adminUserTask.Update(user);
                return(CloseParentBox("修改成功!", "/Home/LogInIndex"));
            }
            return(View());
        }
Exemplo n.º 13
0
        public ActionResult Save(SaveAdminUserModel savemodel)
        {
            ViewBag.RoleList = _adminUserRoleTask.GetAll().ToSelectList(c => c.RoleId.ToString(), c => c.RoleName);

            if (ModelState.IsValid)
            {
                if (savemodel.AdminUserId == null)
                {
                    var model = new AdminUser
                    {
                        UserName = savemodel.UserName,
                        Password = CryptTools.HashPassword(savemodel.Password),
                        IsLock   = false,
                        RoleId   = savemodel.RoleId
                    };
                    _adminUserTask.Add(model);
                }
                else
                {
                    var model = _adminUserTask.GetById((int)savemodel.AdminUserId);

                    if (model == null)
                    {
                        return(AlertMsg("参数错误", HttpContext.Request.UrlReferrer.PathAndQuery));
                    }

                    model.UserName = savemodel.UserName;
                    model.Password = CryptTools.HashPassword(savemodel.Password);
                    model.RoleId   = savemodel.RoleId;

                    _adminUserTask.Update(model);
                }
                return(AlertMsg("保存成功", HttpContext.Request.UrlReferrer.PathAndQuery));
            }
            return(View(savemodel));
        }
    private void Save()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";
        int?id = null;

        if (!string.IsNullOrEmpty(Request.Form["id"]))
        {
            id = Convert.ToInt32(Request.Form["id"]);
        }
        UserInfo model = null;

        if (!id.HasValue)//新增
        {
            var entiy = userBll.Get(Request.Form["UserName"]);
            if (entiy != null)
            {
                result.Msg = "用户名存在!";
            }
            else
            {
                model = new UserInfo()
                {
                    UserName          = Request.Form["UserName"],
                    Password          = CryptTools.HashPassword(Request.Form["Password"]),
                    Mobile            = Request.Form["Mobile"],
                    Status            = byte.Parse(Request.Form["Status"] ?? "0"),
                    IsGeneralAviation = byte.Parse(Request.Form["IsGeneralAviation"]),
                    CompanyCode3      = byte.Parse(Request.Form["IsGeneralAviation"]) == 1 ? Request.Form["CompanyCode3"] : "",
                    CreateTime        = DateTime.Now
                };
                if (userBll.Add(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "增加成功!";
                }
            }
        }
        else//编辑
        {
            model = userBll.Get(id.Value);
            if (model != null)
            {
                model.UserName = Request.Form["UserName"];
                //  model.Password = CryptTools.HashPassword(Request.Form["Password"]);
                model.Mobile            = Request.Form["Mobile"];
                model.Status            = byte.Parse(Request.Form["Status"] ?? "0");
                model.IsGeneralAviation = byte.Parse(Request.Form["IsGeneralAviation"] ?? "0");
                model.CompanyCode3      = model.IsGeneralAviation == 1 ? Request.Form["CompanyCode3"] : "";

                if (userBll.Update(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "更新成功!";
                }
            }
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }