/// <inheritdoc /> public async Task SaveNewTokenAsync(RefreshToken refreshToken) { var existingTokens = context.RefreshTokens.Where(t => t.UserId == refreshToken.UserId); context.RefreshTokens.RemoveRange(existingTokens); await context.RefreshTokens.AddAsync(refreshToken); await context.SaveChangesAsync(); }
public async Task Broadcast(string message) { var user = await userManager.GetUserAsync(Context.User); if (Dictionary.TryGetValue(user.Id, out var keys)) { message = CryptoService.Decrypt(message, keys); await dbContext.Messages.AddAsync(new Message { Sender = user, Text = message }); await dbContext.SaveChangesAsync(); await Clients.All.SendAsync("Broadcast", CryptoService.Encrypt(user.Email, keys), CryptoService.Encrypt(message, keys)); } }
/// <inheritdoc /> public async Task LogAsync(SecurityAudit log) { context.SecurityAudit.Add(log); await context.SaveChangesAsync(); }