예제 #1
0
        return JsonView::render($response);
    }
    if ($response['success']) {
        unset($response['message']);
        $response['last_page'] = json_decode($user['last_page']);
        $set = array('last_login' => new Expression('NOW()'));
        $where = array('id' => $user['id']);
        $updateResult = $Users->update($set, $where);
        $Activity = new DirectusActivityTableGateway($acl, $ZendDb);
        $Activity->recordLogin($user['id']);
    }
    JsonView::render($response);
})->name('auth_login');
$app->get("/{$v}/auth/logout(/:inactive)", function ($inactive = null) use($app) {
    if (Auth::loggedIn()) {
        Auth::logout();
    }
    if ($inactive) {
        $app->redirect(DIRECTUS_PATH . "login.php?inactive=1");
    } else {
        $app->redirect(DIRECTUS_PATH . "login.php");
    }
})->name('auth_logout');
$app->get("/{$v}/auth/nonces/?", function () use($app, $requestNonceProvider) {
    $all_nonces = $requestNonceProvider->getAllNonces();
    $response = array('nonces' => $all_nonces);
    JsonView::render($response);
})->name('auth_nonces');
// debug helper
$app->get("/{$v}/auth/session/?", function () use($app) {
    if ('production' === DIRECTUS_ENV) {
예제 #2
0
        $host = 'https://' . $_SERVER['SERVER_NAME'];
        if ('80' != $_SERVER['SERVER_PORT']) {
            $host .= ':' . $_SERVER['SERVER_PORT'];
        }
        $httpsUrl = $host . $_SERVER['REQUEST_URI'];
        header('Location: ' . $httpsUrl);
        exit;
    }
}
$users = getUsers();
// hotfix
// @NOTE: if the user doesn't have permission to view users
// it should be log out
// see: https://github.com/directus/directus/issues/1268
if (!$users) {
    AuthProvider::logout();
    $_SESSION['error_message'] = 'Your user doesn\'t have permission to log in';
    header('Location: ' . DIRECTUS_PATH . 'login.php');
    exit;
}
$currentUserInfo = getCurrentUserInfo($users);
// Cache buster
$git = __DIR__ . '/.git';
$cacheBuster = Directus\Util\Git::getCloneHash($git);
$tableSchema = TableSchema::getAllSchemas($currentUserInfo['group']['id'], $cacheBuster);
// $tabPrivileges = getTabPrivileges(($currentUserInfo['group']['id']));
$groupId = $currentUserInfo['group']['id'];
$groups = getGroups();
$currentUserGroup = [];
if (isset($groups['rows']) && count($groups['rows'] > 0)) {
    foreach ($groups['rows'] as $group) {