Skip to content

Commit

Permalink
Fixed issue with last activity date format in properties
Browse files Browse the repository at this point in the history
  • Loading branch information
melittleman committed Feb 26, 2024
1 parent 16e104c commit 460a504
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Authentication/RedisTicketStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ public async Task RenewAsync(string key, AuthenticationTicket ticket)
{
if (ticket.Properties.ExpiresUtc.HasValue)
{
Db.KeyExpire(redisKey, ticket.Properties.ExpiresUtc.Value.UtcDateTime);
// TODO: Do we care about failure here?
// It does mean that the user could technically be logged in forever...
_ = await Db.KeyExpireAsync(redisKey, ticket.Properties.ExpiresUtc.Value.UtcDateTime);
}

// We only ever need to set the cached ticket to a very short expiration
// just to ease the network IO out to Redis when the ticket store is hit a
// number of times in a row, for example on an initial page load.
_cache.Set(redisKey, ticket, _cacheExpiry);
}

// TODO: Probably need to add some logging into here for failures / errors etc.
}

/// <inheritdoc />
Expand All @@ -132,7 +136,11 @@ public async Task RenewAsync(string key, AuthenticationTicket ticket)

// TODO: Can this set task cause an exception when the key doesn't exist? I think it can,
// which means we need a way to capture this exception and continue even when it fails.
Task<bool> setTask = Json.SetAsync(redisKey, jsonPath, lastActivity, serializerOptions: _jsonOptions.Serializer);
Task<bool> setTask = Json.SetAsync(
redisKey,
jsonPath,
lastActivity.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture),
serializerOptions: _jsonOptions.Serializer);

Task<AuthenticationTicket?> getTask = Json.GetAsync<AuthenticationTicket>(redisKey, serializerOptions: _jsonOptions.Serializer);

Expand Down

0 comments on commit 460a504

Please sign in to comment.