重构代码:AccountController控制器Login方法减少一次Redirect直接返回登录未成功视图
This commit is contained in:
parent
296ac82a4c
commit
4da9abd056
Bootstrap.Admin/Controllers
|
@ -47,11 +47,12 @@ namespace Bootstrap.Admin.Controllers
|
||||||
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
|
var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
|
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" });
|
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { ExpiresUtc = DateTimeOffset.Now.AddDays(DictHelper.RetrieveCookieExpiresPeriod()), IsPersistent = remember == "true" });
|
||||||
}
|
|
||||||
// redirect origin url
|
// redirect origin url
|
||||||
var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index";
|
var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index";
|
||||||
return Redirect(originUrl);
|
return Redirect(originUrl);
|
||||||
}
|
}
|
||||||
|
return View("Login", new ModelBase());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue