Skip to content

Commit 5434f9e

Browse files
committed
Return 'other' if no standard account type is found in API
Also rename variables and comment to clarify that the listed types are not the only ones allowed, just the ones suggested/ mentioned in the CLICS specification (as examples). Closes: #3163
1 parent eedd68a commit 5434f9e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

webapp/src/Entity/User.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,21 @@ public function getRoleList(): array
436436
#[Serializer\Type('string')]
437437
public function getType(): ?string
438438
{
439-
// Types allowed by the CCS Specs Contest API in order of most permissions to least.
439+
// Types suggested by the CCS Specs Contest API in order of most permissions to least.
440440
// Either key=>value where key is the DOMjudge role and value is the API account type or
441441
// only value, where both the DOMjudge role and API type are the same.
442-
$allowedTypes = ['admin', 'api_writer' => 'admin', 'api_reader' => 'admin',
443-
'jury' => 'judge', 'api_source_reader' => 'judge',
444-
'team'];
445-
foreach ($allowedTypes as $role => $allowedType) {
442+
$mappedTypes = ['admin', 'api_writer' => 'admin', 'api_reader' => 'admin',
443+
'jury' => 'judge', 'api_source_reader' => 'judge', 'team'];
444+
foreach ($mappedTypes as $role => $mappedType) {
446445
if (is_numeric($role)) {
447-
$role = $allowedType;
446+
$role = $mappedType;
448447
}
449448
if (in_array($role, $this->getRoleList())) {
450-
return $allowedType;
449+
return $mappedType;
451450
}
452451
}
453452

454-
return null;
453+
return 'other';
455454
}
456455

457456
/**

0 commit comments

Comments
 (0)