Elgg  Version master
RegistrationAllowedGatekeeper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Router\Middleware;
4 
6 use Elgg\Request;
7 
16 
25  public function __invoke(Request $request): void {
26  if ($this->validateInviteCode($request)) {
27  return;
28  }
29 
31  }
32 
42  protected function validateInviteCode(Request $request): bool {
43  $friend_guid = (int) $request->getParam('friend_guid');
44  $invitecode = $request->getParam('invitecode');
45 
46  if (empty($friend_guid) || empty($invitecode)) {
47  return false;
48  }
49 
50  $friend = get_user($friend_guid);
51  if (!$friend instanceof \ElggUser) {
52  return false;
53  }
54 
55  if (elgg_validate_invite_code($friend->username, $invitecode)) {
56  return true;
57  }
58 
59  throw new RegistrationAllowedGatekeeperException(elgg_echo('RegistrationAllowedGatekeeperException:invalid_invitecode'));
60  }
61 
68  protected function assertRegistrationEnabled(): void {
69  if (_elgg_services()->config->allow_registration) {
70  return;
71  }
72 
74  }
75 }
elgg_validate_invite_code(string $username, string $code)
Validate a user&#39;s invite code.
Definition: users.php:198
validateInviteCode(Request $request)
Validate the optional invite code.
$request
Definition: livesearch.php:12
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
__invoke(Request $request)
Validate input and/or settings to allow access to registration resources.
getParam($key, $default=null, $filter=true)
Get an element of the params array.
Definition: Request.php:67
$friend_guid
Assembles and outputs the registration page.
Definition: register.php:12
assertRegistrationEnabled()
Validate if registration is allowed by the site configuration.
Validate that registration is allowed based on one of the following:
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
$invitecode
Definition: register.php:13
Request container.
Definition: Request.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351