diff --git a/src/Infrastructure/HttpUserContext/IUserContext.cs b/src/Infrastructure/HttpUserContext/IUserContext.cs index 18d52c9..784f907 100644 --- a/src/Infrastructure/HttpUserContext/IUserContext.cs +++ b/src/Infrastructure/HttpUserContext/IUserContext.cs @@ -57,7 +57,7 @@ public interface IUserContext where TId : IEquatable /// /// JwtTokenInfo GenerateTokenInfo(IList? claims = null, - double? duration = null, + double duration = 0, string schemeName = JwtBearerDefaults.AuthenticationScheme); /// diff --git a/src/Infrastructure/HttpUserContext/UserContext.cs b/src/Infrastructure/HttpUserContext/UserContext.cs index 38d06c7..b9ecb70 100644 --- a/src/Infrastructure/HttpUserContext/UserContext.cs +++ b/src/Infrastructure/HttpUserContext/UserContext.cs @@ -91,11 +91,11 @@ public class UserContext( public JwtTokenInfo GenerateTokenInfo( IList? claims = null, - double? duration = null, + double duration = 0, string schemeName = JwtBearerDefaults.AuthenticationScheme) { claims ??= GetClaimsFromUserContext(); - if (double.NaN == duration) + if (0 == duration) { duration = jwtContext.Duration; } @@ -106,12 +106,12 @@ public class UserContext( Audience = jwtContext.Audience, Claims = claims?.ToDictionary(c => c.Type, c => (object)c.Value), NotBefore = DateTime.Now, - Expires = DateTime.Now.AddSeconds(duration.Value), + Expires = DateTime.Now.AddSeconds(duration), SigningCredentials = jwtContext.SigningCredentials, }; var token = jsonWebTokenHandler.CreateToken(tokenDescriptor); token = encryptionService.Encrypt(token); - return new JwtTokenInfo(token, duration.Value, schemeName); + return new JwtTokenInfo(token, duration, schemeName); } public IList? GetClaimsFromUserContext(bool includePermissions = false)