Join requests now present an "are you sure?" modal

This commit is contained in:
2022-03-08 16:11:09 +00:00
parent 52b5a880b2
commit a07ec92546
5 changed files with 96 additions and 35 deletions

View File

@@ -105,7 +105,7 @@ class OrganisationMembersController extends SimpleController
Capsule::transaction(function () use ($organisation, $currentUser, $classMapper, $config) {
$organisation->members()->attach($currentUser->id, [
'flag_admin' => false,
'flag_approved' => !$config['organisation']['membership']['require_approval'],
'flag_approved' => !$config['organisation.membership.require_approval'],
]);
$organisation->save();
@@ -976,6 +976,55 @@ class OrganisationMembersController extends SimpleController
return $sprunje->toResponse($response);
}
/**
* Get join confirmation modal.
*
* @param Request $request
* @param Response $response
* @param array $args
*
* @throws NotFoundException If organisation is not found
* @throws ForbiddenException If user is not authorized to access page
* @throws BadRequestException
*/
public function getModalConfirmJoin(Request $request, Response $response, $args)
{
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */
$authorizer = $this->ci->authorizer;
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = $this->ci->classMapper;
/** @var \UserFrosting\Support\Repository\Repository $config */
$config = $this->ci->config;
/** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */
$currentUser = $this->ci->currentUser;
$organisation = $this->getOrganisationFromParams($args);
// If the organisation no longer exists, forward to main organisation listing page
if (!$organisation) {
throw new NotFoundException();
}
// Access-controlled page
if (!$authorizer->checkAccess($currentUser, 'join_organisation', [
'organisation' => $organisation,
])) {
throw new ForbiddenException();
}
return $this->ci->view->render($response, 'modals/confirm-join-organisation.html.twig', [
'organisation' => $organisation,
'approval_required' => $config['organisation.membership.require_approval'],
'form' => [
'action' => "api/organisations/o/{$organisation->slug}/members",
],
]);
}
/**
* Get leave confirmation modal.
*