public Task <T> GetAsync(string key) { return(Task <T> .Factory.StartNew(() => { using (var db = new CoreDbContext(ConnectionString)) { Entities.Token dbCode = db.Tokens.FirstOrDefault(c => c.Key == key); if (dbCode == null || dbCode.Expiry < DateTime.UtcNow) { return null; } return JsonConvert.DeserializeObject <T>(dbCode.JsonCode, _jsonSerializerSettings); } })); }
public override Task StoreAsync(string key, RefreshToken value) { using (var db = new CoreDbContext(ConnectionString)) { var efToken = new Entities.Token { Key = key, JsonCode = ConvertToJson(value), Expiry = DateTime.UtcNow.AddSeconds(value.LifeTime), TokenType = TokenType }; db.Tokens.Add(efToken); db.SaveChanges(); } return(Task.FromResult(0)); }
public override Task StoreAsync(string key, AuthorizationCode code) { using (var db = new CoreDbContext(ConnectionString)) { var efCode = new Entities.Token { Key = key, JsonCode = ConvertToJson(code), Expiry = DateTime.UtcNow.AddSeconds(code.Client.AuthorizationCodeLifetime), TokenType = this.TokenType }; db.Tokens.Add(efCode); db.SaveChanges(); } return(Task.FromResult(0)); }
public override Task StoreAsync(string key, Token value) { return(Task.Factory.StartNew(() => { using (var db = new CoreDbContext(ConnectionString)) { var efToken = new Entities.Token { Key = key, JsonCode = JsonConvert.SerializeObject(value), Expiry = DateTime.UtcNow.AddSeconds(value.Lifetime) }; db.Tokens.Add(efToken); db.SaveChanges(); } })); }