Skip to content

Commit

Permalink
Update serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Aug 29, 2024
1 parent 296f9b2 commit a2111f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Extensions.Caching.Distributed;
using Newtonsoft.Json;
using System.Text.Json;

namespace MvcHybridBackChannel.BackChannelLogout;

Expand Down Expand Up @@ -31,12 +31,12 @@ public void Add(string sub, string sid)
_logger.LogInformation("BC logoutSession: {logoutSession}", logoutSession);
if (logoutSession != null)
{
var session = JsonConvert.DeserializeObject<BackchannelLogoutSession>(logoutSession);
var session = JsonSerializer.Deserialize<BackchannelLogoutSession>(logoutSession);
}
else
{
var newSession = new BackchannelLogoutSession { Sub = sub, Sid = sid };
_cache.SetString(key, JsonConvert.SerializeObject(newSession), options);
_cache.SetString(key, JsonSerializer.Serialize(newSession), options);
}
}
}
Expand All @@ -49,7 +49,7 @@ public async Task<bool> IsLoggedOutAsync(string sub, string sid)
var logoutSession = await _cache.GetStringAsync(key);
if (logoutSession != null)
{
var session = JsonConvert.DeserializeObject<BackchannelLogoutSession>(logoutSession);
var session = JsonSerializer.Deserialize<BackchannelLogoutSession>(logoutSession);
matches = session.IsMatch(sub, sid);

Check warning on line 53 in MvcHybridBackChannel/BackChannelLogout/LogoutSessionManager.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
_logger.LogInformation("BC Logout session exists T/F {matches} : {sub}, sid: {sid}", matches, sub, sid);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Extensions.Caching.Distributed;
using Newtonsoft.Json;
using System.Text.Json;

namespace MvcHybridBackChannelTwo.BackChannelLogout;

Expand Down Expand Up @@ -31,12 +31,12 @@ public void Add(string sub, string sid)
_logger.LogInformation("BC logoutSession: {logoutSession}", logoutSession);
if (logoutSession != null)
{
var session = JsonConvert.DeserializeObject<BackchannelLogoutSession>(logoutSession);
var session = JsonSerializer.Deserialize<BackchannelLogoutSession>(logoutSession);
}
else
{
var newSession = new BackchannelLogoutSession { Sub = sub, Sid = sid };
_cache.SetString(key, JsonConvert.SerializeObject(newSession), options);
_cache.SetString(key, JsonSerializer.Serialize(newSession), options);
}
}
}
Expand All @@ -49,11 +49,11 @@ public async Task<bool> IsLoggedOutAsync(string? sub, string? sid)
var logoutSession = await _cache.GetStringAsync(key);
if (logoutSession != null)
{
var session = JsonConvert.DeserializeObject<BackchannelLogoutSession>(logoutSession);
var session = JsonSerializer.Deserialize<BackchannelLogoutSession>(logoutSession);
matches = session!.IsMatch(sub, sid);
_logger.LogInformation("BC Logout session exists T/F {matches} : {sub}, sid: {sid}", matches, sub, sid);
}

return matches;
}
}
}

0 comments on commit a2111f4

Please sign in to comment.