public static function authenticate(&$token)
 {
     if (!isset($token)) {
         $msg = new Messages($GLOBALS['locale']);
         Util::output_errors_and_die($msg->_('/authentication/auth-required'), 403);
     }
     try {
         $model = new Model();
         $user_data = $model->is_valid_auth_token($token);
         return $user_data;
     } catch (DatabaseException $e) {
         Util::output_errors_and_die($e->getMessage(), 503);
         die;
     } catch (Exception $e) {
         Util::output_errors_and_die($e->getMessage(), 400);
     }
 }
Example #2
0
<?php

$msg = new Messages($GLOBALS['locale']);
$db_created = file_exists(get_config_dir() . '/dbsettings.ini');
try {
    $model = new Model($first_run = !$db_created);
} catch (DatabaseException $e) {
    exit_with_message($msg->_('/showmsg/database-error'));
    die;
}
$has_manager = ($db_created and $model->has_manager());
if (!$has_manager) {
    header('Location: firstrun');
    die;
}
if (isset($_COOKIE['authToken'])) {
    $user_data = $model->is_valid_auth_token($_COOKIE['authToken']);
    if ($user_data) {
        include 'home.html.php';
        die;
    }
}
// not logged in
include 'login.html.php';