Skip to content

Commit c98c494

Browse files
committed
#12374 Fix issue preventing users from accepting invitations while logged out
1 parent 98b04bf commit c98c494

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

api/v1/_i18n/I18nController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Illuminate\Http\Response;
2222
use Illuminate\Support\Facades\Route;
2323
use PKP\core\PKPBaseController;
24+
use PKP\core\PKPRequest;
2425
use PKP\facades\Locale;
2526

2627
class I18nController extends PKPBaseController
@@ -49,6 +50,16 @@ public function getGroupRoutes(): void
4950
Route::get('ui.js', $this->getTranslations(...))->name('_i18n.getTranslations');
5051
}
5152

53+
54+
/**
55+
* @copydoc \PKP\core\PKPBaseController::authorize()
56+
*/
57+
public function authorize(PKPRequest $request, array &$args, array $roleAssignments): bool
58+
{
59+
// No authorization required for publicly accessible endpoint
60+
return true;
61+
}
62+
5263
/**
5364
* Provides javascript file which includes all translations used in Vue.js UI.
5465
*/

api/v1/invitations/InvitationController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ class InvitationController extends PKPBaseController
4141
public const PARAM_ID = 'invitationId';
4242
public const PARAM_KEY = 'key';
4343

44+
public array $publicActions = [
45+
'receive',
46+
'finalize',
47+
'refine',
48+
'decline',
49+
];
50+
4451
public $actionsInvite = [
4552
'get',
4653
'populate',
@@ -184,6 +191,10 @@ public function authorize(PKPRequest $request, array &$args, array $roleAssignme
184191
$invitationId = (int) $this->getParameter(self::PARAM_ID);
185192
$invitationKey = $this->getParameter(self::PARAM_KEY);
186193

194+
if(in_array($actionName, $this->publicActions)){
195+
$this->setEnforceRestrictedSite(false);
196+
}
197+
187198
if (in_array($actionName, $this->requiresType)) {
188199
if (!isset($invitationType)) {
189200
throw new Exception("Parameter with the name '" . self::PARAM_TYPE . "' needs to be declared");

classes/security/authorization/RestrictedSiteAccessPolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function effect(): int
7676
*/
7777
private function _getLoginExemptions(): array
7878
{
79-
$exemptions = ['user', 'login', 'help', 'header', 'sidebar', 'payment'];
79+
$exemptions = ['user', 'login', 'help', 'header', 'sidebar', 'payment', 'invitation'];
8080
Hook::call('RestrictedSiteAccessPolicy::_getLoginExemptions', [[&$exemptions]]);
8181
return $exemptions;
8282
}

0 commit comments

Comments
 (0)