示例#1
0
文件: Manager.php 项目: bolt/Members
 /**
  * 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;
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * 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');
 }
示例#4
0
 /**
  * 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;
 }
示例#5
0
文件: Manager.php 项目: bolt/Members
 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.');
 }
示例#6
0
 /**
  * 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]);
     }
 }
示例#7
0
 /**
  * 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;
 }
示例#8
0
文件: Roles.php 项目: bolt/Members
 /**
  * Add the extension's configured roles.
  */
 protected function buildPriorityRoles()
 {
     foreach ($this->config->getRolesMember() as $name => $displayName) {
         $this->roles[$name] = new Role($name, $displayName);
     }
 }