public async Task RemoveAsync(string key) { var token = await context.Tokens.FindAsync(key, tokenType); if (token != null) { context.Tokens.Remove(token); await context.SaveChangesAsync(); } }
public async Task UpdateAsync(Thinktecture.IdentityServer.Core.Models.Consent consent) { var item = await context.Consents.FindAsync(consent.Subject, consent.ClientId); if (item == null) { item = new Entities.Consent { Subject = consent.Subject, ClientId = consent.ClientId }; context.Consents.Add(item); } if (consent.Scopes == null || !consent.Scopes.Any()) { context.Consents.Remove(item); } item.Scopes = StringifyScopes(consent.Scopes); await context.SaveChangesAsync(); }
private async Task ClearTokens() { try { Logger.Info("Clearing tokens"); using (var db = new OperationalDbContext(this.options.ConnectionString, this.options.Schema)) { var query = from token in db.Tokens where token.Expiry < DateTimeOffset.UtcNow select token; db.Tokens.RemoveRange(query); await db.SaveChangesAsync(); } } catch (Exception ex) { Logger.ErrorException("Exception cleanring tokens", ex); } }
private async Task ClearTokens() { try { Logger.Info("Clearing tokens"); using (var db = new OperationalDbContext(this.options.ConnectionString, this.options.Schema)) { var query = from token in db.Tokens where token.Expiry < DateTimeOffset.UtcNow select token; db.Tokens.RemoveRange(query); await db.SaveChangesAsync(); } } catch(Exception ex) { Logger.ErrorException("Exception cleanring tokens", ex); } }