Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
filter allowed type of member
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl authored and backportbot[bot] committed Dec 13, 2021
commit 3beb11caeb4ad03ac1bb41b03a142768407467ab
6 changes: 6 additions & 0 deletions lib/FederatedItems/SingleMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ protected function generateMember(FederatedEvent $event, Circle $circle, Member
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[120], 120);
}

$allowedTypes = $this->configService->getAppValueInt(ConfigService::ALLOWED_TYPES);
if ($federatedUser->getUserType() < Member::TYPE_APP
&& ($allowedTypes & $federatedUser->getUserType()) === 0) {
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[132], 132);
}

if ($federatedUser->getBasedOn()->isConfig(Circle::CFG_ROOT)) {
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[125], 125);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Model/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class Member extends ManagedModel implements
public const TYPE_CIRCLE = 16;
public const TYPE_APP = 10000;

public const ALLOWING_ALL_TYPES = 31;

public const APP_CIRCLES = 10001;
public const APP_OCC = 10002;

Expand Down
3 changes: 3 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ConfigService {
public const SELF_SIGNED_CERT = 'self_signed_cert';
public const MEMBERS_LIMIT = 'members_limit';
public const ACTIVITY_ON_NEW_CIRCLE = 'creation_activity';
public const ALLOWED_TYPES = 'allowed_types';

public const MIGRATION_BYPASS = 'migration_bypass';
public const MIGRATION_22 = 'migration_22';
Expand Down Expand Up @@ -176,6 +177,8 @@ class ConfigService {
self::SELF_SIGNED_CERT => '0',
self::MEMBERS_LIMIT => '-1',
self::ACTIVITY_ON_NEW_CIRCLE => '1',
self::ALLOWED_TYPES => Member::ALLOWING_ALL_TYPES,

self::MIGRATION_BYPASS => '0',
self::MIGRATION_22 => '0',
self::MIGRATION_22_1 => '0',
Expand Down
3 changes: 2 additions & 1 deletion lib/StatusCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class StatusCode {
128 => 'Cannot add Circle as its own Member',
129 => 'Member does not contains a patron',
130 => 'Member is invited by an entity that does not belongs to the instance at the origin of the request',
131 => 'Member is a non-local Circle'
131 => 'Member is a non-local Circle',
132 => 'Member type not allowed'
];

public static $MEMBER_LEVEL = [
Expand Down