public async System.Threading.Tasks.Task <Microsoft.AspNetCore.Mvc.IActionResult> Login(Models.ViewModels.LoginModel accountViewModel)
        {
            if (ModelState.IsValid)
            {
                Microsoft.AspNetCore.Identity.IdentityUser user = await userManager.FindByNameAsync(accountViewModel.Name);

                if (user != null)
                {
                    await signInManager.SignOutAsync();

                    if ((await signInManager.PasswordSignInAsync(user, accountViewModel.Password, false, false)).Succeeded)
                    {
                        return(Redirect(accountViewModel?.ReturnUrl ?? "/Admin/Index"));
                    }
                }
            }
            ModelState.AddModelError("", "Invalid name or password");
            return(View(accountViewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Logout()
        {
            await signInManager.SignOutAsync();

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