Example #1
0
    if (!$appconf['Custom Handlers']['user/login']) {
        echo $this->error(404, i18n_get('Not found'), i18n_get('The page you requested could not be found.'));
        return;
    }
    echo $this->run($appconf['Custom Handlers']['user/login'], $data);
    return;
}
if (!$this->internal) {
    $page->title = i18n_get('Members');
}
if (isset($_GET['redirect'])) {
    $_POST['redirect'] = $_GET['redirect'];
}
if (!isset($_POST['redirect'])) {
    $_POST['redirect'] = $_SERVER['REQUEST_URI'];
    if ($_POST['redirect'] == '/user/login') {
        $_POST['redirect'] = '/user';
    }
}
if (!Form::verify_value($_POST['redirect'], 'header')) {
    $_POST['redirect'] = '/user';
}
if (!User::require_login()) {
    if (!$this->internal && !empty($_POST['username'])) {
        echo '<p>' . i18n_get('Incorrect email or password, please try again.') . '</p>';
    }
    $_POST['signup_handler'] = $appconf['Custom Handlers']['user/signup'];
    echo $tpl->render('user/login', $_POST);
} elseif (!$this->internal) {
    $this->redirect($_POST['redirect']);
}
Example #2
0
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/User.php';
require_once dirname(__FILE__) . '/Account.php';
$user = User::require_login();
if (array_key_exists('account', $_GET)) {
    $account = Account::getByID($_GET['account']);
    if (!is_null($account)) {
        $account->setAsCurrent($user);
    }
}
if (array_key_exists('return', $_GET)) {
    $return_to = $_GET['return'];
} else {
    $return_to = UserConfig::$USERSROOTURL . '/manage_account.php';
}
header('Location: ' . $return_to);
Example #3
0
 /**
  * Generate the top-level menu for the sections of your app.
  *
  * @param string|bool $current
  *
  * @return string
  */
 public static function menu($current = false)
 {
     if (!\User::require_login()) {
         return '';
     }
     $customer = self::customer();
     if (!$customer) {
         return '';
     }
     $conf = self::$conf;
     if (!is_array($conf['Sections'])) {
         $conf['Sections'] = array();
     }
     if (!$current) {
         $current = Section::get();
     }
     $out = '<ul class="nav">';
     foreach ($conf['Sections'] as $key => $value) {
         if (strpos($key, 'dropdown:') === 0) {
             // handle dropdown menu options
             $key = str_replace('dropdown:', '', $key);
             $label = array_shift($value);
             $out .= '<li class="dropdown">' . '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . $label . ' <b class="caret"></b></a>' . '<ul class="dropdown-menu">';
             foreach ($value as $handler => $label) {
                 $out .= sprintf('<li><a href="%s">%s</a></li>', self::make_href($handler), $label);
             }
             $out .= '</ul></li>';
             continue;
         }
         // handle regular menu options
         $class = $current && $current === $key ? ' class="active"' : '';
         $out .= sprintf('<li%s><a href="%s/%s">%s</a></li>', $class, self::href(), $key, array_shift($value));
     }
     // Add account
     $class = strpos($_SERVER['REQUEST_URI'], '/saasy/account') === 0 ? ' class="active"' : '';
     $out .= sprintf('<li%s><a href="%s/%s">%s</a></li>', $class, self::href(), 'account', __('Account'));
     // Add sign out
     $out .= sprintf('<li><a href="/user/logout">%s</a></li>', __('Sign Out'));
     return $out . '</ul>';
 }
Example #4
0
<?php

require_once dirname(dirname(__FILE__)) . '/config.php';
require_once dirname(dirname(__FILE__)) . '/User.php';
$current_user = User::require_login();
if (!in_array($current_user->getID(), UserConfig::$admins)) {
    require_once dirname(__FILE__) . '/admin_access_only.php';
    exit;
}
if (array_key_exists('impersonate', $_POST)) {
    $impersonated_user = User::getUser($_POST['impersonate']);
    if ($impersonated_user !== null) {
        $impersonated_user->setSession(false);
        // always impersonate only for the browser session
        header('Location: ' . UserConfig::$DEFAULTLOGINRETURN);
    } else {
        header('Location: #msg=cantimpersonate');
    }
}
require_once UserConfig::$header;
if (!isset($ADMIN_SECTION)) {
    $ADMIN_SECTION = null;
}
if (UserConfig::$enableInvitations) {
    ?>
<h2>Users | <a href="invitations.php">Invitations</a></h2><?php 
}
?>
<div style="background: white; padding: 0">
<h3>
<?php 
Example #5
0
 /**
  * Require the user to be logged in to proceed with the request.
  * If not, it will redirect to the appropriate login handler.
  */
 public function require_login($redirect = '/user/login')
 {
     if (!User::require_login()) {
         $this->redirect($redirect . '?redirect=' . urlencode($_SERVER['REQUEST_URI']));
     }
 }