public async Task <IActionResult> Login(AppUserLoginModel model) { if (ModelState.IsValid) { if (appUserService.CheckUser(model.UserName, model.Password)) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.UserName), new Claim(ClaimTypes.Role, "Admin"), }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { IsPersistent = model.RememberMe }; await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(RedirectToAction("Index", "Home", new { @area = "Admin" })); } ModelState.AddModelError("", "Kullanıcı adı veya parola hatalı"); } return(View(model)); }
public async Task <IActionResult> SignIn(AppUserLoginDto appUserLoginDto) { if (ModelState.IsValid) { if (await _appUserService.CheckUser(appUserLoginDto.Email, appUserLoginDto.Password)) { await CookieConfiguration(appUserLoginDto.Email, appUserLoginDto.Password, appUserLoginDto.RememberMe); //giriş başarılı return(RedirectToAction("Index", "Home", new { @area = "Admin" })); } //giriş başarısız ModelState.AddModelError("", "Kullanıcı adı yada parola hatalı."); } return(View(appUserLoginDto)); }
public async Task <IActionResult> Login(AppUserLoginModel model) { if (ModelState.IsValid) { if (_appUserService.CheckUser(model.Username, model.Password)) { await CookieConfiguration(model.Username, model.Password, model.RememberMe); //giriş başarılı return(RedirectToAction("Index", "Home", new { @area = "Admin" })); } //giriş başarısız ModelState.AddModelError("", "Kullanıcı adı yada parola hatalı."); } return(View(model)); }