public function main() { $template = new Template('example.phpt'); $template->set('title', Config::get('app.name')); $template->set('first', Config::get('app.example.first')); $template->set('second', Config::get('app.example.second')); $template->set('third', Config::get('app.example.third')); $template->set('counts', Config::get('app.example')); return Response::template($template); }
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); }
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); }
<?php // Initialize router $router = new \Neuron\Router(); // Accounts module $signinmodule = new \CatLab\Accounts\Module(); $signinmodule->requireEmailValidation(); //$signinmodule->setLayout ('index-account.phpt'); $password = new \CatLab\Accounts\Authenticators\Password(); $signinmodule->addAuthenticator($password); $facebook = new \CatLab\Accounts\Authenticators\Facebook(); $signinmodule->addAuthenticator($facebook); $steam = new \CatLab\Accounts\Authenticators\Steam(); $signinmodule->addAuthenticator($steam); $mailer = new \CatLab\Mailer\Module(); $router->module('/mailer', $mailer); // Make the module available on /account $router->module('/account', $signinmodule); $router->get('/thirdparty', function () { $request = \Neuron\Application::getInstance()->getRouter()->getRequest(); $deligatedAccounts = $request->getUser()->getDeligatedAccounts(); return \Neuron\Net\Response::template('thirdparty.phpt', array('accounts' => $deligatedAccounts)); })->filter('authenticated'); // Catch the default route $router->get('/', function () { return \Neuron\Net\Response::template('home.phpt'); }); return $router;
/** * @return Response */ public function requiresVerification() { $user = null; $userId = $this->request->getSession()->get('catlab-non-verified-user-id'); if ($userId) { $user = \Neuron\MapperFactory::getUserMapper()->getFromId($userId); } if (!$user || !$user instanceof User) { return Response::error('You are not logged in.'); } if ($user->isEmailVerified()) { return $this->module->login($this->request, $user); } $template = new Template('CatLab/Accounts/notverified.phpt'); // Send verification. if ($this->request->input('retry')) { $user->sendVerificationEmail($this->module); } $template->set('layout', $this->module->getLayout()); $template->set('user', $user); $template->set('resend_url', URLBuilder::getURL($this->module->getRoutePath() . '/notverified', array('retry' => 1))); return Response::template($template); }
/** * @return bool|Response|string */ public function register() { $template = new Template('CatLab/Accounts/authenticators/password/register.phpt'); if ($this->request->isPost()) { $email = $this->request->input('email', 'email'); $username = $this->request->input('username', 'username'); $password = $this->request->input('password'); $response = $this->processRegister($email, $username, $password); if ($response instanceof Response) { return $response; } else { if (is_string($response)) { $template->set('error', $response); } } } $template->set('layout', $this->module->getLayout()); $template->set('action', URLBuilder::getURL($this->module->getRoutePath() . '/register/' . $this->getToken())); $template->set('email', $this->request->input('email', 'string')); $template->set('username', $this->request->input('username', 'string')); return Response::template($template); }
private function linkExitingAccount(DeligatedUser $deligatedUser) { $page = new Template('CatLab/Accounts/authenticators/deligated/link.phpt'); if ($this->request->isPost()) { $email = $this->request->input('email'); $password = $this->request->input('password'); $response = $this->processLogin($deligatedUser, $email, $password); if ($response instanceof Response) { return $response; } else { if (is_string($response)) { $page->set('error', $response); } } } $page->set('layout', $this->module->getLayout()); $page->set('action', URLBuilder::getURL($this->module->getRoutePath() . '/register/' . $this->getToken(), array('link' => 1))); $page->set('return', URLBuilder::getURL($this->module->getRoutePath() . '/register/' . $this->getToken())); // Name if ($name = $deligatedUser->getWelcomeName()) { $page->set('name', $name); } // Email. if ($email = $this->request->input('email')) { $page->set('email', $email); } else { if ($email = $deligatedUser->getEmail()) { $page->set('email', $email); } else { $page->set('email', ''); } } return Response::template($page); }