-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc6ded5
commit 68f803b
Showing
6 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# autologin | ||
Auto Login - Skip the login page if you are already authenticated in GLPI | ||
# Auto Login (GLPI) | ||
This plugin skip the login page if you are already authenticated in GLPI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<root> | ||
<name>Auto Login</name> | ||
<key>autologin</key> | ||
<state>stable</state> | ||
<logo>https://raw.githubusercontent.com/edgardmessias/autologin/master/plugin.png</logo> | ||
<description> | ||
<short> | ||
<en><![CDATA[This plugin skip the login page if you are already authenticated.]]></en> | ||
</short> | ||
<long> | ||
<en><![CDATA[This plugin skip the login page if you are already authenticated.]]></en> | ||
</long> | ||
</description> | ||
<homepage>https://github.com/edgardmessias/autologin</homepage> | ||
<download>https://github.com/edgardmessias/autologin/releases</download> | ||
<issues>https://github.com/edgardmessias/autologin/issues</issues> | ||
<readme>https://github.com/edgardmessias/autologin/wiki</readme> | ||
<authors> | ||
<author>Edgard Lorraine Messias</author> | ||
</authors> | ||
<versions> | ||
<version> | ||
<num>1.0.0</num> | ||
<compatibility>0.85</compatibility> | ||
<compatibility>0.90</compatibility> | ||
<compatibility>9.1</compatibility> | ||
</version> | ||
</versions> | ||
<langs> | ||
<lang>Any</lang> | ||
</langs> | ||
<license><![CDATA[GPL v2+]]></license> | ||
<tags> | ||
<en> | ||
<tag>Authentication</tag> | ||
<tag>Login</tag> | ||
<tag>AutoLogin</tag> | ||
</en> | ||
</tags> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
function plugin_autologin_install() { | ||
return true; | ||
} | ||
|
||
function plugin_autologin_uninstall() { | ||
return true; | ||
} | ||
|
||
function plugin_autologin_display_login() { | ||
global $CFG_GLPI; | ||
|
||
if (!Session::getLoginUserID()) { | ||
return false; | ||
} | ||
|
||
// Redirect management | ||
$REDIRECT = ""; | ||
if (isset($_POST['redirect']) && (strlen($_POST['redirect']) > 0)) { | ||
$REDIRECT = "?redirect=" . rawurlencode($_POST['redirect']); | ||
} else if (isset($_GET['redirect']) && strlen($_GET['redirect']) > 0) { | ||
$REDIRECT = "?redirect=" . rawurlencode($_GET['redirect']); | ||
} | ||
|
||
$url = false; | ||
|
||
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { | ||
if ($_SESSION['glpiactiveprofile']['create_ticket_on_login'] && empty($REDIRECT)) { | ||
$url = $CFG_GLPI['root_doc'] . "/front/helpdesk.public.php?create_ticket=1"; | ||
} else { | ||
$url = $CFG_GLPI['root_doc'] . "/front/helpdesk.public.php$REDIRECT"; | ||
} | ||
} else { | ||
if ($_SESSION['glpiactiveprofile']['create_ticket_on_login'] && empty($REDIRECT)) { | ||
$url = $CFG_GLPI['root_doc'] . "/front/ticket.form.php"; | ||
} else { | ||
$url = $CFG_GLPI['root_doc'] . "/front/central.php$REDIRECT"; | ||
} | ||
} | ||
|
||
echo "\n<!-- Begin AutoLogin -->\n"; | ||
echo "<div style=\"text-align: center\">\n"; | ||
echo "<img src=\"" . $CFG_GLPI['root_doc'] . "/plugins/autologin/pics/loading.gif\" />\n"; | ||
echo "</div>\n"; | ||
echo "<script type=\"text/javascript\">\n"; | ||
echo "document.getElementById('login_name').disabled=true;\n"; | ||
echo "document.getElementById('login_name').style.backgroundColor=\"#DDD\";\n"; | ||
echo "document.getElementById('login_password').disabled=true;\n"; | ||
echo "document.getElementById('login_password').style.backgroundColor=\"#DDD\";\n"; | ||
echo "window.location = " . json_encode($url) . ";\n"; | ||
echo "</script>\n"; | ||
echo "<!-- End AutoLogin -->\n"; | ||
return true; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
// Init the hooks of the plugins -Needed | ||
function plugin_init_autologin() { | ||
global $PLUGIN_HOOKS; | ||
|
||
$PLUGIN_HOOKS['csrf_compliant']['autologin'] = true; | ||
|
||
$PLUGIN_HOOKS['display_login']['autologin'] = 'plugin_autologin_display_login'; | ||
} | ||
|
||
// Get the name and the version of the plugin - Needed | ||
function plugin_version_autologin() { | ||
return array( | ||
'name' => 'Auto Login', | ||
'version' => '1.0.0', | ||
'author' => 'Edgard Lorraine Messias', | ||
'homepage' => 'https://github.com/edgardmessias/autologin', | ||
'minGlpiVersion' => '0.85' | ||
); | ||
} | ||
|
||
// Optional : check prerequisites before install : may print errors or add to message after redirect | ||
function plugin_autologin_check_prerequisites() { | ||
if (version_compare(GLPI_VERSION, '0.85', 'lt')) { | ||
echo "This plugin requires GLPI >= 0.85"; | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
function plugin_autologin_check_config() { | ||
return true; | ||
} |