/**
  * @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;
 }
 public function templates()
 {
     Template::addPath('lowpriority', '', -5);
     Template::addPath('regularpriority', '', 0);
     Template::addPath('highpriority', '', 5);
     return Response::table(Template::getPaths());
 }
Example #3
0
 /**
  * Set template paths, config vars, etc
  * @param string $routepath The prefix that should be added to all route paths.
  * @return void
  */
 public function initialize($routepath)
 {
     // Set path
     $this->routepath = $routepath;
     // Add templates
     Template::addPath(__DIR__ . '/../templates/', 'CatLab/OAuth2/');
     Application::getInstance()->on('dispatch:before', array($this, 'setRequestUser'));
     // Add locales
     Text::getInstance()->addPath('catlab.oauth2', __DIR__ . '/locales/');
     $this->setErrorResponder(new JSON());
 }
 /**
  * Set template paths, config vars, etc
  * @param string $routepath The prefix that should be added to all route paths.
  * @return void
  */
 public function initialize($routepath)
 {
     $this->routepath = $routepath;
     Template::addPath(__DIR__ . '/templates/', 'CatLab/OpenIDClient/');
     // Set session variable
     Application::getInstance()->on('dispatch:before', array($this, 'setRequestUser'));
     // Set the global user mapper, unless one is set already
     Application::getInstance()->on('dispatch:first', array($this, 'setUserMapper'));
     // Add helper methods
     $helper = new LoginForm($this);
     Template::addHelper('CatLab.OpenIDClient.LoginForm', $helper);
 }
 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);
 }
Example #6
0
 /**
  * @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;
     }
 }
Example #7
0
 /**
  * Set template paths, config vars, etc
  * @param string $routepath The prefix that should be added to all route paths.
  * @return void
  */
 public function initialize($routepath)
 {
     // Set path
     $this->routepath = $routepath;
     // Add templates
     Template::addPath(__DIR__ . '/templates/', 'CatLab/Accounts/');
     // Add locales
     Text::getInstance()->addPath('catlab.accounts', __DIR__ . '/locales/');
     // Set session variable
     Application::getInstance()->on('dispatch:before', array($this, 'setRequestUser'));
     // Set the global user mapper, unless one is set already
     Application::getInstance()->on('dispatch:first', array($this, 'setUserMapper'));
     // Add helper methods
     $helper = new LoginForm($this);
     Template::addHelper('CatLab.Accounts.LoginForm', $helper);
 }
 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);
 }
Example #9
0
 /**
  *
  */
 private function __construct()
 {
     Template::addPath(dirname(dirname(__FILE__)) . '/templates/', '', -1);
 }
Example #10
0
<?php

error_reporting(E_ALL);
$loader = (require_once '../../vendor/autoload.php');
// Start the app
$app = \Neuron\Application::getInstance();
// Set config folder
\Neuron\Config::folder(__DIR__ . '/../config/');
// Optionally, set an environment
$hostname = trim(file_get_contents('/etc/hostname'));
switch ($hostname) {
    case 'my-computer':
    case 'thijs-home-i7':
    case 'thijs-i7':
        \Neuron\Config::environment('development');
        break;
}
// Set the template folder
\Neuron\Core\Template::addPath(__DIR__ . '/../templates/');
// Always set a locale
$app->setLocale('nl_BE.utf8');
// Load the router
$app->setRouter(include 'router.php');
// Return app
return $app;
 /**
  * @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);
 }
Example #12
0
 public function sendConfirmationEmail(Module $module)
 {
     return;
     $template = new Template('CatLab/Accounts/mails/confirmation.phpt');
     $template->set('user', $this);
     $mail = new Mail();
     $mail->setSubject('Email verification');
     $mail->setTemplate($template);
     $mail->getTo()->add($this->getEmail());
     $mail->setFrom(Config::get('mailer.from.email'));
     Mailer::getInstance()->send($mail);
 }
Example #13
0
 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;
 }
Example #14
0
 private function setTemplate(Template $template)
 {
     $this->setBody($template->parse());
     $this->setOutput(new HTML());
     return $this;
 }
 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;
 }