From 460a5047481da9ba7c907a4be1c17cb8d73e59ae Mon Sep 17 00:00:00 2001 From: Matt Lindsay Date: Mon, 26 Feb 2024 09:32:23 +0000 Subject: [PATCH] Fixed issue with last activity date format in properties --- src/Authentication/RedisTicketStore.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Authentication/RedisTicketStore.cs b/src/Authentication/RedisTicketStore.cs index 3e08b97..5187be4 100644 --- a/src/Authentication/RedisTicketStore.cs +++ b/src/Authentication/RedisTicketStore.cs @@ -98,7 +98,9 @@ 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 @@ -106,6 +108,8 @@ public async Task RenewAsync(string key, AuthenticationTicket ticket) // 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. } /// @@ -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 setTask = Json.SetAsync(redisKey, jsonPath, lastActivity, serializerOptions: _jsonOptions.Serializer); + Task setTask = Json.SetAsync( + redisKey, + jsonPath, + lastActivity.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture), + serializerOptions: _jsonOptions.Serializer); Task getTask = Json.GetAsync(redisKey, serializerOptions: _jsonOptions.Serializer);