Esempio n. 1
0
        internal async Task HandlePersonRequirement(AuthorizationHandlerContext context,
                                                    PersonEditRequirement requirement,
                                                    Func <Guid> personId)
        {
            if (context.User.IsAdminOrHr() || context.User.IsHighLevelSupervisor() ||
                context.User.IsInRole("registrar"))
            {
                context.Succeed(requirement);
                return;
            }

            var supervisorGroupId = context.User.SupervisorGroupId() ?? Guid.Empty;

            if (!context.User.IsSupervisor() || supervisorGroupId == Guid.Empty)
            {
                context.Fail();
                return;
            }

            if (await _orgGroupService.IsPersonInGroup(personId(), supervisorGroupId))
            {
                context.Succeed(requirement);
            }
        }
Esempio n. 2
0
 public async Task ShouldShowPersonInGroup()
 {
     (await _groupService.IsPersonInGroup(org1aStaff.Id, org1.Id)).ShouldBeTrue();
     (await _groupService.IsPersonInGroup(org1aStaff.Id, org2.Id)).ShouldBeFalse();
 }