Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Api/Middlewares/ExceptionMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private async void HandleLimitExceededException(HttpContext context, Exception e

private async void HandleAuthenticationException(HttpContext context, Exception ex)
{
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
context.Response.StatusCode = StatusCodes.Status400BadRequest;
await WriteExceptionMessageAsync(context, ex);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Api/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"JweSettings": {
"SigningKeyId": "4bd28be8eac5414fb01c5cbe343b50144bd28be8eac5414fb01c5cbe343b50144bd28be8eac5414fb01c5cbe343b50144bd28be8eac5414fb01c5cbe343b50144bd28be8eac5414fb01c5cbe343b5014",
"EncryptionKeyId": "4bd28be8eac5414fb01c5cbe343b5014",
"TokenLifetime": "00:00:05",
"TokenLifetime": "00:20:00",
"RefreshTokenLifetimeInDays": 3
},
"Seed": true,
Expand Down
11 changes: 0 additions & 11 deletions src/Infrastructure/Identity/IdentityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,6 @@ public async Task<AuthenticationResult> RefreshTokenAsync(string token, string r
{
throw new AuthenticationException("Invalid token.");
}

var expiryDateUnix =
long.Parse(validatedToken.Claims.Single(x => x.Type.Equals(JwtRegisteredClaimNames.Exp)).Value);

var expiryDateTimeUtc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
.AddSeconds(expiryDateUnix);

if (expiryDateTimeUtc > DateTime.UtcNow)
{
throw new AuthenticationException("This token has not expired yet.");
}

var jti = validatedToken.Claims.Single(x => x.Type.Equals(JwtRegisteredClaimNames.Jti)).Value;
var storedRefreshToken = await _context.RefreshTokens.SingleOrDefaultAsync(x => x.Token.Equals(Guid.Parse(refreshToken)));
Expand Down