Skip to content

Commit

Permalink
First Release;
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Dec 31, 2016
1 parent fc6ded5 commit 68f803b
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
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
41 changes: 41 additions & 0 deletions autologin.xml
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>
55 changes: 55 additions & 0 deletions hook.php
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;
}
Binary file added pics/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions setup.php
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;
}

0 comments on commit 68f803b

Please sign in to comment.