Exemplo n.º 1
0
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = _userService.SignIn(model.UserName, MD5.ToMD5String(model.Password, "ljtx"));

            if (result != null)
            {
                HttpContext.Session.SetString("abpblogsession", CompressHelper.AES_Encrypt(model.UserName, "qwertyuiop", "1234567891234567"));
                Logger.InfoFormat("Logged in {userName}.", model.UserName);
                return(RedirectToLocal(returnUrl));
            }
            else
            {
                Logger.WarnFormat("Failed to log in {userName}.", model.UserName);
                ModelState.AddModelError("", "用户名或密码错误");
                return(View(model));
            }
        }