Beispiel #1
0
        public ActionResult Login(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                ModelState.AddModelError("username", "请输入用户名");
                return(View());
            }

            if (string.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("password", "请输入密码");
                return(View());
            }

            AuthBll bll = new AuthBll();

            sysmatchuser usr = bll.Login(username, password);

            if (usr == null)
            {
                ModelState.Clear();
                ModelState.AddModelError("error", "用户名密码不正确");
                return(View());
            }
            else
            {
                base.UserInfo = usr;

                return(RedirectToAction("Index", "Login", new { Area = "Auth" }));
            }
        }
Beispiel #2
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="name"></param>
 /// <param name="pwd"></param>
 /// <returns></returns>
 public sysmatchuser Login(string name, string pwd)
 {
     using (BFdbContext db = new BFdbContext())
     {
         IEnumerable <sysmatchuser> users = db.FindAll <sysmatchuser>(p => p.Account == name && p.Pwd == pwd && p.Status == 0);
         if (users.Count() < 1)
         {
             return(null);
         }
         else
         {
             sysmatchuser usr = users.First();
             return(usr);
         }
     }
 }
Beispiel #3
0
        public ActionResult ModifyPwd(sysmatchuser model)
        {
            if (model.NewPassword == model.Pwd)
            {
                ModelState.AddModelError("NewPassword", "新密码与旧密码一致,修改失败");
                return(View(model));
            }

            if (model.NewPassword != model.ConfirmPassword)
            {
                ModelState.AddModelError("ConfirmPassword", "密码输入不一致");
                return(View(model));
            }

            string oldpwd = model.Pwd;
            string newpwd = model.NewPassword;

            var bll = new UserBll();

            model = bll.GetMatchUser(base.UserInfo.Id);

            if (model.Pwd != oldpwd)
            {
                ModelState.AddModelError("Password", "旧密码输入错误");
                return(View(model));
            }

            model.Pwd = newpwd;

            try
            {
                bll.Update <sysmatchuser>(model);
            }
            catch (ValidException ex)
            {
                this.ModelState.AddModelError(ex.Name, ex.Message);
                return(View(model));
            }

            return(this.RefreshParent());
        }
Beispiel #4
0
        public ActionResult ModifyPwd()
        {
            sysmatchuser usr = new sysmatchuser();

            return(View(usr));
        }