Пример #1
0
 public MembersController(
     IOwnerService ownerService,
     IMemberService memberService,
     IAuthedUserService authedUserService
     )
 {
     _ownerService      = ownerService;
     _memberService     = memberService;
     _authedUserService = authedUserService;
 }
 public CodingEventsController(
     IOwnerService ownerService,
     IMemberService memberService,
     IAuthedUserService authedUserService,
     IPublicAccessService publicAccessService,
     ICodingEventTagService codingEventTagService
     )
 {
     _ownerService          = ownerService;
     _memberService         = memberService;
     _authedUserService     = authedUserService;
     _publicAccessService   = publicAccessService;
     _codingEventTagService = codingEventTagService;
 }
Пример #3
0
        public Task InvokeAsync(HttpContext context, IAuthedUserService authedUserService)
        {
            var authedUser = context.User;

            // not authenticated or already has the userId claim added (unlikely but guard for future)
            if (!authedUser.Identity.IsAuthenticated || authedUser.FindFirstValue("userId") != null)
            {
                return(_next(context));
            }

            var user = authedUserService.GetOrCreateUserFromActiveDirectory(authedUser);

            // inject user id into context.User
            authedUser.Identities.FirstOrDefault()
        ? // prevent NPE if no identity is found (unlikely but suppress warning)
            .AddClaim(new Claim("userId", user.Id.ToString()));

            return(_next(context));
        }