重构代码:AccountController控制器Login方法减少一次Redirect直接返回登录未成功视图

This commit is contained in:
Argo Zhang 2019-03-13 18:25:32 +08:00
parent 296ac82a4c
commit 4da9abd056
1 changed files with 4 additions and 3 deletions

View File

@ -47,10 +47,11 @@ namespace Bootstrap.Admin.Controllers
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { ExpiresUtc = DateTimeOffset.Now.AddDays(DictHelper.RetrieveCookieExpiresPeriod()), IsPersistent = remember == "true" });
// redirect origin url
var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index";
return Redirect(originUrl);
}
// redirect origin url
var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index";
return Redirect(originUrl);
return View("Login", new ModelBase());
}
/// <summary>