Exemplo n.º 1
0
Arquivo: app.php Projeto: svlt/front
 /**
  * Initialize the app
  */
 static function init()
 {
     // Initialize Composer autoloader
     require_once 'vendor/autoload.php';
     // Initialize framework
     self::$_fw = Base::instance();
     self::$_fw->mset(['AUTOLOAD' => 'app/', 'ESCAPE' => false, 'PREFIX' => 'dict.', 'PACKAGE' => 'svlt/front', 'UI' => 'app/view/', 'JAR.httponly' => false]);
     // Load configuration
     if (is_file('config.php')) {
         self::$_fw->mset(require 'config.php');
     } else {
         throw new Exception('No config.php file found.');
     }
     // Initialize routes
     require_once 'routes.php';
     // Load user if any
     if ($token = self::$_fw->get('COOKIE.session_token')) {
         $user = \Helper\Api\User::get('me');
         if (isset($user->id)) {
             self::$_fw->set('user', $user);
         }
     }
     // Run app
     self::$_fw->run();
 }
Exemplo n.º 2
0
Arquivo: user.php Projeto: svlt/front
 /**
  * GET|POST /logout
  * @param \Base $fw
  */
 function logout(\Base $fw)
 {
     if ($fw->get('COOKIE.session_token') == $fw->get('GET.session')) {
         \Helper\Api\User::logout();
         $fw->set('COOKIE.session_token', null);
         $fw->reroute('/');
     } else {
         $fw->error(400);
     }
 }
Exemplo n.º 3
0
Arquivo: index.php Projeto: svlt/front
 /**
  * POST /register
  * @param \Base $fw
  */
 function registerPost(\Base $fw)
 {
     try {
         $token = \Helper\Api\User::register($fw->get('POST'));
         $fw->set('COOKIE.session_token', $token);
         $fw->reroute('/stream');
     } catch (\Exception $e) {
         $fw->set('error', $e->getMessage());
         \App::error(403);
     }
 }