Пример #1
0
        /// <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();
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
 /// <inheritdoc />
 public async Task LogAsync(SecurityAudit log)
 {
     context.SecurityAudit.Add(log);
     await context.SaveChangesAsync();
 }