コード例 #1
0
        private static async Task <string> GetSessionId(IUserCookieManager cookieManager, HttpContext context)
        {
            var(status, sid) = await cookieManager.GetSessionIdSafe(context.Request);

            return(status == ValidateUserSessionStatus.Ok && sid.HasValue
                ? $"{sid.Value:D}".Substring(0, 8)
                : "No session");
        }
コード例 #2
0
 public AuthorizedActionFilter(
     ILogger <AuthorizedActionFilter> logger,
     IUserCookieManager cookieManager,
     UserRole[] roles)
 {
     this.logger        = logger;
     this.cookieManager = cookieManager;
     this.roles         = roles;
 }
コード例 #3
0
        public async Task InvokeAsync(HttpContext context, ILogger <LogContextMiddleware> logger,
                                      IUserCookieManager cookieManager)
        {
            var requestId = context.TraceIdentifier;
            var sessionId = await GetSessionId(cookieManager, context);

            using (logger.BeginScope($"[{requestId}] [{sessionId}]"))
            {
                logger.LogInformation($"Start controller call {context.Request.Path}");
                await next(context);

                logger.LogInformation($"Finish controller call {context.Request.Path}. Response status code {context.Response.StatusCode}");
            }
        }
コード例 #4
0
 public InviteController(
     IAsyncRepository <Invite> invitesRepo,
     IAsyncRepository <AuthenticationAccount> authenticationAccountRepo,
     IAsyncRepository <User> userRepo,
     IOptions <ConfigOptions> options,
     IUserCookieManager userCookieManager
     )
 {
     this.invitesRepo = invitesRepo;
     this.authenticationAccountRepo = authenticationAccountRepo;
     this.userRepo          = userRepo;
     this.options           = options;
     this.userCookieManager = userCookieManager;
 }
コード例 #5
0
 public UsersController(
     ILogger <UsersController> logger,
     IUserCookieManager userCookieManager,
     IAuthenticationManager authenticationManager,
     IUserManager userManager,
     IAsyncRepository <User> usersRepo,
     IAsyncRepository <AuthenticationAccount> authenticationAccountRepo,
     IAsyncRepository <Invite> invitesRepo
     )
 {
     this.logger                    = logger;
     this.userCookieManager         = userCookieManager;
     this.authenticationManager     = authenticationManager;
     this.userManager               = userManager;
     this.usersRepo                 = usersRepo;
     this.authenticationAccountRepo = authenticationAccountRepo;
     this.invitesRepo               = invitesRepo;
 }
コード例 #6
0
 public ContestsController(IContestManager contestManager, IAsyncRepository <Contest> contestsRepo, IUserCookieManager cookieManager)
 {
     this.contestManager = contestManager;
     this.contestsRepo   = contestsRepo;
     this.cookieManager  = cookieManager;
 }