Skip to content

Commit b5f5fb2

Browse files
authored
Fix a UTC Time conversion bug
The UTC time offset is currently converted straight to a DateTime in the computer's local timezone. It is then passed into the CognitoUserSession constructor, where it is converted to a universal time. If you're in a timezone +'ve of UTC this means that IsValid on the CognitoUserSession will always return false, which breaks a number of other methods in the User Manager (anything that checks for authentication).
1 parent 6a303b4 commit b5f5fb2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Amazon.AspNetCore.Identity.Cognito/CognitoUserManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private async Task PopulateTokens(TUser user, string claimType, string claimValu
165165
var refreshToken = await _httpContextAccessor.HttpContext.GetTokenAsync(OpenIdConnectParameterNames.RefreshToken).ConfigureAwait(false);
166166
var idToken = await _httpContextAccessor.HttpContext.GetTokenAsync(OpenIdConnectParameterNames.IdToken).ConfigureAwait(false);
167167

168-
user.SessionTokens = new CognitoUserSession(idToken, accessToken, refreshToken, result.Properties.IssuedUtc.Value.DateTime, result.Properties.ExpiresUtc.Value.DateTime);
168+
user.SessionTokens = new CognitoUserSession(idToken, accessToken, refreshToken, result.Properties.IssuedUtc.Value.UtcDateTime, result.Properties.ExpiresUtc.Value.UtcDateTime);
169169
}
170170
}
171171
}

0 commit comments

Comments
 (0)