/** * Return the combined login & registration resolved form object. * * @param Request $request The client Request object being processed. * @param string $twigParent Parent Twig template to be used. * * @return ResolvedFormBuild */ protected function getFormCombinedLogin(Request $request, $twigParent) { $resolvedBuild = new ResolvedFormBuild(); $resolvedBuild->setContext(['twigparent' => $twigParent]); /** @var Builder\Associate $builder */ $builder = $this->formGenerator->getFormBuilder(MembersForms::FORM_ASSOCIATE); $builder->setAction(sprintf('/%s/login', $this->config->getUrlAuthenticate())); $associateForm = $builder->createForm([])->handleRequest($request); $resolvedBuild->addBuild(MembersForms::FORM_ASSOCIATE, $builder, $associateForm); /** @var Builder\LoginOauth $builder */ $builder = $this->formGenerator->getFormBuilder(MembersForms::FORM_LOGIN_OAUTH); $builder->setAction(sprintf('/%s/login', $this->config->getUrlAuthenticate())); $formOauth = $builder->createForm([])->handleRequest($request); $resolvedBuild->addBuild(MembersForms::FORM_LOGIN_OAUTH, $builder, $formOauth); /** @var Builder\LoginPassword $builder */ $builder = $this->formGenerator->getFormBuilder(MembersForms::FORM_LOGIN_PASSWORD); $builder->setAction(sprintf('/%s/login', $this->config->getUrlAuthenticate())); $formPassword = $builder->createForm([])->handleRequest($request); $resolvedBuild->addBuild(MembersForms::FORM_LOGIN_PASSWORD, $builder, $formPassword); /** @var Builder\ProfileRegister $builder */ $builder = $this->formGenerator->getFormBuilder(MembersForms::FORM_PROFILE_REGISTER); $builder->setAction(sprintf('/%s/profile/register', $this->config->getUrlMembers())); $formRegister = $builder->createForm([])->handleRequest($request); if ($this->session->isTransitional()) { } $resolvedBuild->addBuild(MembersForms::FORM_PROFILE_REGISTER, $builder, $formRegister); return $resolvedBuild; }
/** * Create and store the account record. * * @param Profile $entity * * @return Storage\Entity\Account */ protected function createAccount(Profile $entity) { $displayName = $entity->getDisplayname(); $emailAddress = $entity->getEmail(); $account = $this->records->createAccount($displayName, $emailAddress, $this->config->getRolesRegister()); $this->records->saveAccount($account); return $account; }
/** * Display the registration form. * * @param TwigEnvironment $twigEnvironment * @param string $template * * @return TwigMarkup */ public function renderRegister(TwigEnvironment $twigEnvironment, $template = null) { $context = ['transitional' => $this->session->isTransitional()]; $template = $template ?: $this->config->getTemplate('profile', 'register'); $form = $this->formManager->getFormProfileRegister(new Request(), false); $html = $this->formManager->renderForms($form, $twigEnvironment, $template, $context); return new TwigMarkup($html, 'UTF-8'); }
/** * Generate the HTML for the verification email. * * @param MembersProfileEvent $event * * @return string */ private function getRegisterHtml(MembersProfileEvent $event) { $meta = $event->getMetaEntityNames(); $query = http_build_query(['code' => $meta[AccountVerification::KEY_NAME]]); $context = ['name' => $event->getAccount()->getDisplayname(), 'email' => $event->getAccount()->getEmail(), 'link' => sprintf('%s/%s/profile/verify?%s', $this->siteUrl, $this->config->getUrlMembers(), $query), 'member' => $event->getAccount()]; $mailHtml = $this->twig->render($this->config->getTemplate('verification', 'body'), $context); return $mailHtml; }
public function onRequest(GetResponseEvent $event) { if (!Zone::isBackend($event->getRequest())) { return; } foreach ($this->config->getRolesAdmin() as $role) { if ($this->users->isAllowed($role)) { return; } } throw new AccessDeniedException('Logged in user does not have the correct rights to use this class.'); }
/** * Dispatch event to any listeners. * * @param string $type Either MembersEvents::MEMBER_LOGIN' or MembersEvents::MEMBER_LOGOUT * @param Authorisation $authorisation */ protected function dispatchEvent($type, Authorisation $authorisation) { if (!$this->dispatcher->hasListeners($type)) { return; } $event = new MembersLoginEvent(); $event->setAccount($authorisation->getAccount()); try { $this->dispatcher->dispatch($type, $event); } catch (\Exception $e) { if ($this->config->isDebug()) { dump($e); } $this->logger->critical('Members event dispatcher had an error', ['event' => 'exception', 'exception' => $e]); } }
/** * Construct the authorisation URL with query parameters. * * @param string $providerName * * @return string */ protected function getCallbackUrl($providerName) { $url = sprintf('%s/%s/oauth2/callback?provider=%s', $this->rootUrl, $this->config->getUrlAuthenticate(), $providerName); $this->logger->debug("[Members][Provider]: Setting callback URL: {$url}"); return $url; }
/** * Add the extension's configured roles. */ protected function buildPriorityRoles() { foreach ($this->config->getRolesMember() as $name => $displayName) { $this->roles[$name] = new Role($name, $displayName); } }