Commit fde08584 authored by nkoth's avatar nkoth

[ENH] Add ability to redirect user to master tiki for login in the new autologin feature

parent 4ed6150d
......@@ -97,6 +97,24 @@ function prefs_login_list()
'default' => 'y',
'tags' => array('advanced'),
),
'login_autologin_redirectlogin' => array(
'name' => tr('Redirect direct logins to this site to remote Tiki'),
'description' => tr('Redirect direct logins to this site to remote Tiki'),
'type' => 'flag',
'default' => 'n',
'dependencies' => array(
'login_autologin_redirectlogin_baseurl',
'permission_denied_login_box',
),
'tags' => array('advanced'),
),
'login_autologin_redirectlogin_url' => array(
'name' => tr('URL of autologin page on remote Tiki to redirect user to login'),
'description' => tr('URL of autologin page on remote Tiki to redirect user to login, e.g. https://www.remotetiki.com/PageWithRedirectPlugin'),
'type' => 'text',
'default' => '',
'tags' => array('advanced'),
),
);
}
......@@ -410,6 +410,9 @@ class TikiAccessLib extends TikiLib
($prefs['permission_denied_login_box'] == 'y' || !empty($prefs['permission_denied_url']))
) {
$_SESSION['loginfrom'] = $_SERVER['REQUEST_URI'];
if ($prefs['login_autologin'] == 'y' && $prefs['login_autologin_redirectlogin'] == 'y' && !empty($prefs['login_autologin_redirectlogin_url'])) {
$this->redirect($prefs['login_autologin_redirectlogin_url']);
}
}
$smarty->assign('errortitle', $detail['errortitle']);
......
......@@ -167,6 +167,7 @@ function wikiplugin_redirect($data, $params)
function get_remotetikiurl($autologin_remotetiki, $redirect_page) {
// Get URL for user to login into remote Tiki
global $user, $base_url;
TikiLib::lib('access')->check_user($user);
$email = TikiLib::lib('user')->get_user_email($user);
$realName = trim(TikiLib::lib('tiki')->get_user_preference($user, 'realName', ''));
$remotetikiurl = $autologin_remotetiki . '/tiki-autologin.php';
......
......@@ -198,6 +198,8 @@
{preference name=login_autologin_allowedgroups}
{preference name=login_autologin_syncgroups}
{preference name=login_autologin_logoutremote}
{preference name=login_autologin_redirectlogin}
{preference name=login_autologin_redirectlogin_url}
</fieldset>
{/tab}
......
......@@ -109,7 +109,9 @@ if ($user == $prefs['login_autologin_user']) {
if (!empty($autologin_base_url)) {
$_SESSION['autologin_base_url'] = $autologin_base_url;
}
if (!empty($page)) {
if (!empty($_SESSION['loginfrom'])) {
TikiLib::lib('access')->redirect($_SESSION['loginfrom']);
} elseif (!empty($page)) {
$sefurl = TikiLib::lib('wiki')->sefurl($page);
TikiLib::lib('access')->redirect($sefurl);
} else {
......
......@@ -10,6 +10,11 @@
$section_class = 'tiki_login'; // This will be body class instead of $section
include_once ("tiki-setup.php");
if ($prefs['login_autologin'] == 'y' && $prefs['login_autologin_redirectlogin'] == 'y' && !empty($prefs['login_autologin_redirectlogin_url'])) {
$access->redirect($prefs['login_autologin_redirectlogin_url']);
}
if (isset($_REQUEST['clearmenucache'])) {
TikiLib::lib('menu')->empty_menu_cache();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment