コード例 #1
0
        public async Task <IActionResult> RevokeAll([FromRoute] string accountId,
                                                    [FromServices] IRevokeAllTokensForAccountCommand revokeAllTokensForAccountCommand)
        {
            try
            {
                //Validate rights

                await revokeAllTokensForAccountCommand.Execute(accountId);

                return(Ok(AuthServer.Common.Messages.Response.Success()));
            }
            catch (InsufficientPermissionsException ex)
            {
                return(Ok(AuthServer.Common.Messages.Response.Success()));
            }
            catch (Exception ex)
            {
                //Log error
                _logger.LogError("RefreshTokenController.RevokeAll", "Exception was thrown", new
                {
                    AccountId = accountId,
                    Exception = ex
                });

                return(BadRequest("Something went wrong"));
            }
        }
        public override async Task ReceiveMessage(IModel model, PasswordChangedEvent message, BasicDeliverEventArgs e, ILogger logger)
        {
            try
            {
                await _revokeAllTokensForAccountCommand.Execute(message.AccountId);

                _logger.LogEvent("PasswordChangedEventConsumer.Consume", $"All tokens revoked for account: {message.AccountId}");
                model.BasicAck(e.DeliveryTag, false);
            }
            catch (Exception ex)
            {
                //Log error
                await _logger.LogErrorAsync("PasswordChangedEventConsumer.Consume", "Exception was thrown", new
                {
                    Message   = message,
                    Exception = ex
                });
            }
        }