コード例 #1
0
        public async Task <IActionResult> Login(LoginModel details, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = await DbMethods.CheckExistUserAsync(userManager, details.Email);

                if (user != null)
                {
                    var result = await DbMethods.CheckPasswordAsync(signInManager, details.Password);

                    if (result)
                    {
                        return(Redirect(returnUrl ?? "/"));
                    }
                }
                ModelState.AddModelError(nameof(LoginModel.Email), "Неправильный логин или пароль");
            }
            return(View(details));
        }