Fixed page_after_login feature - see #5266

skala
Yannick Warnier 13 years ago
parent 8cb94e89d5
commit 72d67dfd1f
  1. 11
      main/inc/lib/redirect.class.php
  2. 6
      main/inc/local.inc.php

@ -35,8 +35,9 @@ class Redirect
/** /**
* Redirect to the session "request uri" if it exists. * Redirect to the session "request uri" if it exists.
* @param bool Whether the user ha just logged in (in this case, use page_after_login rules)
*/ */
static function session_request_uri() static function session_request_uri($logging_in = false)
{ {
// if (api_is_anonymous()) // if (api_is_anonymous())
// { // {
@ -53,9 +54,13 @@ class Redirect
unset($_SESSION['request_uri']); unset($_SESSION['request_uri']);
if ($url) if (!empty($url)) {
{
self::navigate($url); self::navigate($url);
} elseif ($logging_in) {
$pal = api_get_setting('page_after_login');
if (!empty($pal)) {
self::navigate(api_get_path(WEB_PATH).api_get_setting('page_after_login'));
}
} }
} }

@ -154,6 +154,8 @@ $gidReset = isset($gidReset) ? $gidReset : '';
// parameters passed via POST // parameters passed via POST
$login = isset($_POST["login"]) ? $_POST["login"] : ''; $login = isset($_POST["login"]) ? $_POST["login"] : '';
// register if the user is just logging in, in order to redirect him
$logging_in = false;
/* MAIN CODE */ /* MAIN CODE */
@ -279,6 +281,7 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
$_user['status'] = $uData['status']; $_user['status'] = $uData['status'];
Session::write('_user',$_user); Session::write('_user',$_user);
event_login(); event_login();
$logging_in = true;
} else { } else {
$loginFailed = true; $loginFailed = true;
Session::erase('_uid'); Session::erase('_uid');
@ -322,6 +325,7 @@ if (!empty($_SESSION['_user']['user_id']) && ! ($login || $logout)) {
Session::write('_user',$_user); Session::write('_user',$_user);
event_login(); event_login();
$logging_in = true;
} }
} else { } else {
$loginFailed = true; $loginFailed = true;
@ -1100,5 +1104,5 @@ if (isset($_cid)) {
Database::query($sql); Database::query($sql);
} }
Redirect::session_request_uri(); Redirect::session_request_uri($logging_in);

Loading…
Cancel
Save