public CurrentUserService( IHttpContextAccessor httpContextAccessor, IUserIdProvider userIdProvider) { ExternalId = httpContextAccessor.HttpContext?.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value; Id = userIdProvider.Get(ExternalId); }
public override void Handle(ActionExecutingContext context) { var activeRealm = realmService.GetActiveRealm(); var userId = userIdProvider.Get(context.HttpContext); if (realmService.GetRealmPlayer(userId, activeRealm.Id) == null) { context.Result = new RedirectToActionResult("Register", "Nation", null); } else { this.Next(context); } }
public void Send <T>(T command) where T : class, IRequest { if (!(command is CommandBase commandBase)) { _commandProcessor.Send(command); return; } if (!(commandBase is ISkipLogging)) { _commandQueryLogger.LogCommand(command); } commandBase.UserId = _userIdProvider.Get(); _commandProcessor.Send(command); }
public void LogCommand <TCommand>(TCommand command) where TCommand : IRequest { try { var type = command.GetType().ToString(); var commandContent = JsonUtils.Serialize(command); var userId = _userIdProvider.Get(); _logger.LogWarning( "Command. UserId : {userId}. Type : {Type} - {CommandContent}", userId, type, commandContent); } catch (Exception ex) { _logger.LogError(ex, "Error occured while logging query"); } }
public TResult Execute <TResult>(IQuery <TResult> query) { if (!(query is QueryBase <TResult> queryBase)) { return(_decoratee.Execute(query)); } if (!(queryBase is ISkipLogging)) { _commandQueryLogger.LogQuery(query); } if (queryBase.UserId == default) { queryBase.UserId = _userIdProvider.Get(); } return(_decoratee.Execute(queryBase)); }