예제 #1
0
        public async Task <IActionResult> Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await _context.Set <User>().FirstOrDefaultAsync(u => u.Email == model.Email);

                if (user != null)
                {
                    string password = PasswordEncrypt.DecryptStringAes(user.Password, _config.Value.Salt);

                    if (model.Password == password)
                    {
                        await Authenticate(model.Email);

                        return(RedirectToAction("Index", "Home"));
                    }
                }

                ModelState.AddModelError("", "Некорректные логин и(или) пароль");
            }
            return(View(model));
        }