diff --git a/IdentityServer.Application/Services/UserService.cs b/IdentityServer.Application/Services/UserService.cs index 7225d2c..3c7aa88 100644 --- a/IdentityServer.Application/Services/UserService.cs +++ b/IdentityServer.Application/Services/UserService.cs @@ -25,9 +25,9 @@ namespace IdentityServer.Application.Services return null; var tokenRaw = $"{Guid.NewGuid()}-{Guid.NewGuid()}-{user.UserId}"; - _securityStore.SetToken(tokenRaw, user.UserId); + var token = new Token() { Raw = tokenRaw, ValidUntil = DateTime.Now.AddMonths(12) }; + _securityStore.SetToken(token, user.UserId); - var token = new Token() { Raw = tokenRaw }; return token; } diff --git a/IdentityServer.Application/Stores/ISecurityStore.cs b/IdentityServer.Application/Stores/ISecurityStore.cs index a9e8cc5..c46ef8f 100644 --- a/IdentityServer.Application/Stores/ISecurityStore.cs +++ b/IdentityServer.Application/Stores/ISecurityStore.cs @@ -4,7 +4,7 @@ namespace IdentityServer.Application.Stores { public interface ISecurityStore { - void SetToken(string token, int userId); + void SetToken(Token token, int userId); TokenValidation ValidateToken(string token); } } diff --git a/IdentityServer.Application/Stores/SecurityStore.cs b/IdentityServer.Application/Stores/SecurityStore.cs index 6cd8901..6daba27 100644 --- a/IdentityServer.Application/Stores/SecurityStore.cs +++ b/IdentityServer.Application/Stores/SecurityStore.cs @@ -15,14 +15,14 @@ namespace IdentityServer.Application.Stores Tokens = new ConcurrentDictionary>(); } - public void SetToken(string token, int userId) + public void SetToken(Token token, int userId) { var registered = Tokens.TryGetValue(userId, out List list); if (registered) - list.Add(new Token() { Raw = token }); + list.Add(token); else - Tokens.TryAdd(userId, new List() { new Token() { Raw = token } }); + Tokens.TryAdd(userId, new List() { token }); } public TokenValidation ValidateToken(string token)