Example #1
0
        public override async Task ReceiveMessage(IModel model, RefreshTokenRevokedEvent message, BasicDeliverEventArgs e, ILogger logger)
        {
            try
            {
                // Check if revoked token already exists in db.
                if (!(await _revokedTokenRepo.Exists(message.TokenId)))
                {
                    await _revokedTokenRepo.Add(message.TokenId, message.TokenId, message.Expires);

                    _logger.LogInfo("TokenRevokedEventRabbitMqConsumer.Consume", $"Token with key: {message.TokenId} added to revoked tokens.");
                }
                else
                {
                    _logger.LogError("TokenRevokedEventRabbitMqConsumer.Consume", $"Token with key: {message.TokenId} already exists.");
                }
            }
            catch (Exception ex)
            {
                // Log error.
                _logger.LogError("TokenRevokedEventRabbitMqConsumer.Consume", "Exception was thrown", new
                {
                    RefreshTokenRevokedEvent = message,
                    Exception = ex
                });
            }
        }
Example #2
0
        public async Task HandleEvent(RefreshTokenRevokedEvent evnt)
        {
            try
            {
                //Add token to local invalidated tokens list
                await _invalidatedTokenRepo.Add(evnt.TokenId, evnt.TokenId, evnt.Expires);
            }
            catch (Exception ex)
            {
                //Log error
                _logger.LogError("RevokedTokenRedisCacher.HandleEvent", "Exception was thrown", new
                {
                    Exception = ex
                });

                throw;
            }
        }