token store fix

master
Tudor Stanciu 2020-12-24 04:55:45 +02:00
parent f17bb6f151
commit cc6784b073
3 changed files with 6 additions and 6 deletions

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -15,14 +15,14 @@ namespace IdentityServer.Application.Stores
Tokens = new ConcurrentDictionary<int, List<Token>>();
}
public void SetToken(string token, int userId)
public void SetToken(Token token, int userId)
{
var registered = Tokens.TryGetValue(userId, out List<Token> list);
if (registered)
list.Add(new Token() { Raw = token });
list.Add(token);
else
Tokens.TryAdd(userId, new List<Token>() { new Token() { Raw = token } });
Tokens.TryAdd(userId, new List<Token>() { token });
}
public TokenValidation ValidateToken(string token)