Change to JWT inside Secure Cookie Auth
This commit is contained in:
@@ -34,19 +34,9 @@ namespace BoredCareers.Controllers {
|
||||
test.CurrentPasswordAttempts = 0;
|
||||
await _databaseService.SetAccount(test);
|
||||
|
||||
List<Claim> claims = new List<Claim>() {
|
||||
new Claim("ID", test.ID.ToString()),
|
||||
new Claim(ClaimTypes.NameIdentifier, test.ID.ToString())
|
||||
};
|
||||
string jwt = BoredCareersJWT.GenereateJWTToken(test.ID, StayLoggedIn);
|
||||
BoredCareersJWT.SignIn(Response, StayLoggedIn, jwt);
|
||||
|
||||
await HttpContext.SignInAsync(
|
||||
CookieAuthenticationDefaults.AuthenticationScheme,
|
||||
new ClaimsPrincipal(new ClaimsIdentity(claims, "Auth")),
|
||||
new AuthenticationProperties {
|
||||
ExpiresUtc = DateTime.UtcNow.AddYears(30), // Add 30 years with sliding on
|
||||
IsPersistent = StayLoggedIn, // Is set from the StayLoggedIn
|
||||
}
|
||||
);
|
||||
return Ok(test);
|
||||
} else {
|
||||
test.CurrentPasswordAttempts += 1;
|
||||
@@ -151,9 +141,9 @@ namespace BoredCareers.Controllers {
|
||||
|
||||
[Route("logout")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Logout() {
|
||||
public ActionResult Logout() {
|
||||
if (isLoggedIn()) {
|
||||
await HttpContext.SignOutAsync();
|
||||
BoredCareersJWT.SignOut(Response);
|
||||
return Ok();
|
||||
}
|
||||
return NotFound();
|
||||
|
||||
Reference in New Issue
Block a user