Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 524c6ed

Browse files
committed
fix: PerunEnsureMember sends users which are not in vo to regitration
1 parent 294f7c4 commit 524c6ed

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/Auth/Process/PerunEnsureMember.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class PerunEnsureMember extends ProcessingFilter
2323
const INTERFACE_PROPNAME = 'interface';
2424
const CALLBACK_PARAMETER_NAME = 'callbackParameterName';
2525
const RPC = 'rpc';
26-
const GROUP = 'group';
2726

2827
const CALLBACK = 'perun/perun_ensure_member_callback.php';
2928
const REDIRECT = 'perun/perun_ensure_member.php';
@@ -73,8 +72,8 @@ public function __construct($config, $reserved)
7372

7473
public function process(&$request)
7574
{
76-
if (isset($request['perun']['user'])) {
77-
$user = $request['perun']['user'];
75+
if (isset($request[PerunConstants::PERUN][PerunConstants::USER])) {
76+
$user = $request[PerunConstants::PERUN][PerunConstants::USER];
7877
} else {
7978
throw new Exception(
8079
self::LOG_PREFIX . 'Missing mandatory field \'perun.user\' in request.' . 'Hint: Did you configured PerunIdentity filter before this filter?'
@@ -101,15 +100,24 @@ private function handleUser($user, $vo, $request): void
101100
}
102101

103102
$memberStatus = $this->rpcAdapter->getMemberStatusByUserAndVo($user, $vo);
103+
$voHasRegistrationForm = $this->rpcAdapter->hasRegistrationForm($vo->getId(), PerunConstants::VO);
104104
$groupHasRegistrationForm = !empty($this->groupName) && $this->groupHasRegistrationForm($vo, $this->groupName);
105105

106-
if (Member::VALID === $memberStatus && !$isUserInGroup && $groupHasRegistrationForm) {
106+
if (Member::VALID === $memberStatus && $isUserInGroup) {
107+
Logger::debug(self::LOG_PREFIX . 'User is allowed to continue');
108+
} elseif (Member::VALID === $memberStatus && !$isUserInGroup && $groupHasRegistrationForm) {
107109
Logger::debug(self::LOG_PREFIX . 'User is not valid in group ' . $this->groupName . ' - sending to registration');
108110
$this->register($request, $this->groupName);
109-
} elseif (Member::EXPIRED === $memberStatus && $isUserInGroup) {
111+
} elseif (null === $memberStatus && $voHasRegistrationForm && $isUserInGroup) {
112+
Logger::debug(self::LOG_PREFIX . 'User is not member of vo ' . $this->voShortName . ' - sending to registration');
113+
$this->register($request);
114+
} elseif (null === $memberStatus && $voHasRegistrationForm && !$isUserInGroup && $groupHasRegistrationForm) {
115+
Logger::debug(self::LOG_PREFIX . 'User is not member of vo ' . $this->voShortName . ' - sending to registration');
116+
$this->register($request, $this->groupName);
117+
} elseif (Member::EXPIRED === $memberStatus && $voHasRegistrationForm && $isUserInGroup) {
110118
Logger::debug(self::LOG_PREFIX . 'User is expired - sending to registration');
111119
$this->register($request);
112-
} elseif (Member::EXPIRED === $memberStatus && !$isUserInGroup && $groupHasRegistrationForm) {
120+
} elseif (Member::EXPIRED === $memberStatus && $voHasRegistrationForm && !$isUserInGroup && $groupHasRegistrationForm) {
113121
Logger::debug(self::LOG_PREFIX . 'User is expired and is not in group ' . $this->groupName . ' - sending to registration');
114122
$this->register($request, $this->groupName);
115123
} else {
@@ -140,7 +148,7 @@ private function groupHasRegistrationForm($vo, $groupName): bool
140148
}
141149

142150
if (null !== $group) {
143-
return $this->rpcAdapter->hasRegistrationForm($group->getId(), self::GROUP);
151+
return $this->rpcAdapter->hasRegistrationForm($group->getId(), PerunConstants::GROUP);
144152
}
145153

146154
return false;

0 commit comments

Comments
 (0)