/** * @return string */ public function helper() { $request = Application::getInstance()->getRouter()->getRequest(); $template = new Template('CatLab/OpenIDClient/helpers/welcome.phpt'); $template->set('user', $request->getUser()); $template->set('logout', URLBuilder::getURL($this->moduleController->getRoutePath() . '/logout')); $template->set('login', URLBuilder::getURL($this->moduleController->getRoutePath() . '/login', array('return' => $request->getUrl()))); return $template; }
/** * @return Response */ public function register() { // Check for return tag if ($return = $this->request->input('return')) { $this->request->getSession()->set('post-login-redirect', $return); } // Check for cancel tag if ($return = $this->request->input('cancel')) { $this->request->getSession()->set('cancel-login-redirect', $return); } // Check if already registered if ($user = $this->request->getUser()) { return $this->module->postLogin($this->request, $user); } $authenticators = $this->module->getAuthenticators(); $authenticator = $authenticators[0]->getToken(); return Response::redirect(URLBuilder::getURL($this->module->getRoutePath() . '/register/' . $authenticator)); }
public function register() { // Must be logged in if (!($user = $this->request->getUser())) { //echo '<p>' . ('This page is only available for registered users.') . '</p>'; $login = URLBuilder::getURL('account/login', array('return' => $this->module->getURL('register', $_GET))); return Response::redirect($login); } if ($this->request->isPost()) { $template = new Template('CatLab/OAuth2/registerdone.phpt'); $clientid = uniqid('oauth2', true); $password = md5(uniqid('secret')); $redirect_url = $this->request->input('redirecturi'); $layout = $this->request->input('layout'); MapperFactory::getApplicationMapper()->create($clientid, $password, $redirect_url, $layout, $this->request->getUser()->getId()); $template->set('clientid', $clientid); $template->set('clientsecret', $password); $template->set('redirecturi', $redirect_url); return Response::template($template); } $template = new Template('CatLab/OAuth2/register.phpt'); $template->set('action', $this->module->getURL('register')); return Response::template($template); }
/** * @return string */ public function helper() { $request = Application::getInstance()->getRouter()->getRequest(); $user = $request->getUser(); if (!$user) { // The helper should also check for non verified users. $userId = $request->getSession()->get('catlab-non-verified-user-id'); if ($userId) { $user = MapperFactory::getUserMapper()->getFromId($userId); } } if ($user) { $template = new Template('CatLab/Accounts/helpers/welcome.phpt'); $template->set('user', $user); $template->set('logout', URLBuilder::getURL($this->moduleController->getRoutePath() . '/logout')); return $template; } else { $template = new Template('CatLab/Accounts/helpers/form-small.phpt'); $authenticators = $this->moduleController->getAuthenticators(); $authenticators->setRequest($request); $template->set('authenticators', $authenticators); return $template; } }
<?php $app = (include '../bootstrap/start.php'); echo \Neuron\URLBuilder::getAbsoluteURL('test', array('foo' => 'bar'));
private function showAuthorizationDialog($clientdata) { $template = new Template('CatLab/OAuth2/authorize.phpt'); $template->set('clientdata', $clientdata); $template->set('action', URLBuilder::getURL('oauth2/authorize', $_GET)); return \Neuron\Net\Response::template($template); }
public function getVerifyURL($rootPath) { $params = array('token' => $this->getToken()); return URLBuilder::getAbsoluteURL($rootPath . '/verify/' . $this->getId(), $params); }
/** * @param $path * @param array $params * @param bool $normalize * @param null $appurl * @return string */ private function getURL($path, array $params = null, $normalize = true, $appurl = null) { return \Neuron\URLBuilder::getURL($path, $params, $normalize, $appurl); }
public function cancel() { $cancel = $this->request->getSession()->get('cancel-login-redirect'); if ($cancel) { $this->request->getSession()->set('post-login-redirect', null); $this->request->getSession()->set('cancel-login-redirect', null); return Response::redirect($cancel); } else { return Response::redirect(URLBuilder::getURL('/')); } }
public function login() { $this->initialize(); $helper = new FacebookRedirectLoginHelper(URLBuilder::getAbsoluteURL($this->module->getRoutePath() . '/login/' . $this->getToken(), array('next' => 1))); if (!$this->request->input('next')) { $loginUrl = $helper->getLoginUrl($this->scopes); return Response::redirect($loginUrl); } else { try { $session = $helper->getSessionFromRedirect(); } catch (FacebookRequestException $ex) { // When Facebook returns an error return Response::error($ex->getMessage()); } catch (\Exception $ex) { // When validation fails or other local issues return Response::error($ex->getMessage()); } if ($session) { // Check if this user is already registered. $request = new FacebookRequest($session, 'GET', '/me', array('fields' => 'id,name,gender,verified,locale,timezone,email,birthday,first_name,last_name')); $response = $request->execute(); $graphObject = $response->getGraphObject(); $data = $graphObject->asArray(); // Create an object. $user = new DeligatedUser(); $user->setType('facebook'); $user->setUniqueId($data['id']); $user->setAccessToken((string) $session->getAccessToken()); if (isset($data['name'])) { $user->setName($data['name']); } if (isset($data['gender'])) { switch (strtoupper($data['gender'])) { case DeligatedUser::GENDER_FEMALE: case DeligatedUser::GENDER_MALE: $user->setGender(strtoupper($data['gender'])); break; } } if (isset($data['locale'])) { $user->setLocale($data['locale']); } if (isset($data['email'])) { $user->setEmail($data['email']); } if (isset($data['birthday'])) { if (strlen($data['birthday']) == 10) { $parts = explode('/', $data['birthday']); $user->setBirthday(Carbon::createFromDate($parts[2], $parts[0], $parts[1])); } } if (isset($data['first_name'])) { $user->setFirstname($data['first_name']); } if (isset($data['last_name'])) { $user->setLastname($data['last_name']); } $user->setAvatar('https://graph.facebook.com/' . $user->getUniqueId() . '/picture?type=large'); // Touchy touchy! return $this->setDeligatedUser($user); } } }
private function getTrustRoot() { return URLBuilder::getAbsoluteURL($this->module->getRoutePath()); }
/** * @param $subpath * @param array $params * @return string */ public function getURL($subpath, $params = array()) { return URLBuilder::getURL(URLBuilder::partify($this->routepath) . $subpath, $params); }
/** * Called after a redirect * @param Request $request * @return Response */ public function postLogout(Request $request) { return Response::redirect(URLBuilder::getURL('/')); }
public function getInlineForm() { $template = new Template('CatLab/Accounts/authenticators/password/inlineform.phpt'); $template->set('action', URLBuilder::getURL($this->module->getRoutePath() . '/login/password', array('return' => $this->request->getUrl()))); $template->set('email', Tools::getInput($_POST, 'email', 'varchar')); return $template; }
/** * Called after a redirect * @param Request $request * @return Response */ public function postLogout(Request $request) { if ($redirect = $request->getSession()->get('post-login-redirect')) { $request->getSession()->set('post-login-redirect', null); $request->getSession()->set('cancel-login-redirect', null); return Response::redirect($redirect); } return Response::redirect(URLBuilder::getURL('/')); }
public function getInlineForm() { $url = URLBuilder::getURL($this->module->getRoutePath() . '/login/' . $this->getToken()); $page = new Template('CatLab/Accounts/authenticators/deligated/inlineform.phpt'); $page->set('url', $url); $page->set('authenticator', $this); return $page; }