Exemplo n.º 1
0
<?php

namespace CB;

//error_reporting(E_ALL);
//ini_set('display_errors', 1);
if (isset($_GET['state']) && isset($_GET['code'])) {
    require_once __DIR__ . '/classes/CB/Oauth2Utils.php';
    $state = Oauth2Utils::decodeState($_GET['state']);
    if (isset($state['core']) && isset($state['state'])) {
        $_GET['core'] = $state['core'];
        $oauthMode = 1;
        $SESSION_NAME = str_replace(array('.casebox.org', '.', '-'), '', $_SERVER['SERVER_NAME']) . $state['core'];
        // set id of session, to prevent create new session id on redirect
        $_COOKIE[$SESSION_NAME] = $state['state'];
        require_once 'init.php';
        $coreUrl = \CB\Config::get('core_url');
        // $coreUrl = \CB\Config::get('server_name') . $state['core'] . '/';
        $provider = Oauth2Utils::getGoogleProvider();
        $encodedState = Oauth2Utils::getLocalState($provider, $_GET['state'], $_GET['code']);
        header('Location: ' . $coreUrl . 'login/auth/?state=' . $encodedState);
    } else {
        trigger_error('oauth2callback core on encoded state is not set ', E_USER_WARNING);
    }
} else {
    trigger_error('oauth2callback wrong parameters ' . print_r($_GET, true), E_USER_WARNING);
}
Exemplo n.º 2
0
 *
 * This script does first checks on submited values from login.php.
 * Uses the User class and calls Login method with passed params to check authentification validity.
 * If the user passes the authentification he's redirected to the index.php
 * where the CaseBox interface starts loading.
 * Otherwise, if the user do not pass authentification, it is redirected to login.php
 * and the corresponding message is displayed (from $_SESSION['message']).
 *
 * @package CaseBox
 *
 * */
namespace CB;

require_once 'init.php';
if (Oauth2Utils::isOauth2Login()) {
    $Check = Oauth2Utils::checkLogined();
    if ($Check['success']) {
        $r = User::setAsLoged($Check['user_id'], $Check['session_id']);
        if ($r['success'] == false) {
            $errors[] = L\get('Auth_fail');
        } else {
            $cfg = User::getTSVConfig();
            if (!empty($cfg['method'])) {
                $_SESSION['check_TSV'] = time();
                $_SESSION['user']['TSV_checked'] = false;
            } else {
                $_SESSION['user']['TSV_checked'] = true;
            }
        }
        // header('Location: '.Config::get('core_url'));
    } else {
Exemplo n.º 3
0
    echo isset($_SESSION['message']) ? '<div class="alert alert-error">' . $_SESSION['message'] . '</div>' : '';
    ?>
                            <span class="icon-lock"></span>
                        </label>
                        <a style="margin-top: 30px;" class="pull-right" href="<?php 
    echo '/' . $coreName;
    ?>
/recover/forgot-password/"><?php 
    echo L\get('ForgotPassword');
    ?>
</a>
                        <?php 
    $Oauth2Providers = Config::get('oauth2_providers', null);
    if (isset($Oauth2Providers) && in_array('google', explode(',', $Oauth2Providers))) {
        $googleProvider = Oauth2Utils::getGoogleProvider();
        $googleAuthUrl = Oauth2Utils::getLoginUrl($googleProvider);
        if (isset($googleAuthUrl)) {
            echo "<a style='margin-top:25px;margin-right:25px;' class='pull-right' href='" . $googleAuthUrl . "'><img src='/css/i/gplus_signin_button.png' style='height:35px' /></a>";
        }
    }
    ?>
                        <input type="submit" name="s" id="s" value="<?php 
    echo L\get('Login');
    ?>
" class="btn btn-info" style="margin-top: 26px;" disabled>
                        <?php 
} else {
    ?>
                        <label>
                        <?php 
    echo L\get('TSV');