Skip to content
Snippets Groups Projects
Unverified Commit 79cf699c authored by Thijs Kinkhorst's avatar Thijs Kinkhorst Committed by GitHub
Browse files

Merge pull request #953 from tvdijen/admin-logoff

Add logoff button for admin-interface
parents 1534174c 55ce044c
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,26 @@ class Auth
return Module::getModuleURL('core/login-admin.php', array('ReturnTo' => $returnTo));
}
/**
* Retrieve a admin logout URL.
*
* @param string|NULL $returnTo The URL the user should arrive on after admin authentication. Defaults to null.
*
* @return string A URL which can be used for logging out.
* @throws \InvalidArgumentException If $returnTo is neither a string nor null.
*/
public static function getAdminLogoutURL($returnTo = null)
{
if (!(is_string($returnTo) || is_null($returnTo))) {
throw new \InvalidArgumentException('Invalid input parameters.');
}
$as = new \SimpleSAML\Auth\Simple('admin');
return $as->getLogoutURL($returnTo = null);
}
/**
* Check whether the current user is admin.
*
......
......@@ -131,6 +131,9 @@
"loggedin_as_admin": {
"en": "You are logged in as administrator"
},
"logout": {
"en": "Logout"
},
"auth": {
"en": "Authentication"
},
......
......@@ -1355,6 +1355,10 @@
"ro": "V-a\u021bi autentificat ca administrator",
"el": "\u03a3\u03c5\u03bd\u03b4\u03b5\u03b4\u03b5\u03bc\u03ad\u03bd\u03bf\u03c2 \u03c9\u03c2 \u03b4\u03b9\u03b1\u03c7\u03b5\u03b9\u03c1\u03b9\u03c3\u03c4\u03ae\u03c2"
},
"logout": {
"en": "Logout",
"nl": "Uitloggen"
},
"auth": {
"no": "Autentisering",
"sv": "Autentisering",
......
......@@ -166,6 +166,9 @@ msgstr "You are logged in as administrator"
msgid "{core:frontpage:auth}"
msgstr "Authentication"
msgid "{core:frontpage:logout}"
msgstr "Logout"
msgid "{core:no_metadata:suggestion_user_link}"
msgstr ""
"If you are an user who received this error after following a link on a "
......
......@@ -36,6 +36,9 @@ msgstr "Suggesties om dit probleem op te lossen:"
msgid "{core:frontpage:login_as_admin}"
msgstr "Login als beheerder"
msgid "{core:frontpage:logout}"
msgstr "Uitloggen"
msgid "{core:short_sso_interval:warning}"
msgstr ""
"We hebben waargenomen dat u slechts een paar seconden geleden al "
......
......@@ -19,7 +19,9 @@
</div>
<div class="pure-u-1-3">
{% if isadmin %}
<p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}</p>
<p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}
<a href="{{ logouturl }}"><i class="fa fa-sign-out" title="{{ '{core:frontpage:logout}'|trans }}"></i></a>
</p>
{% else %}
<p class="float-r youareadmin">
<a href="{{ loginurl }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a>
......
......@@ -10,6 +10,7 @@ if ($config->getBoolean('admin.protectindexpage', false)) {
}
$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
$links = array();
$links_welcome = array();
......@@ -35,6 +36,7 @@ $t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_auth.tpl.php');
$t->data['pageid'] = 'frontpage_auth';
$t->data['isadmin'] = $isadmin;
$t->data['loginurl'] = $loginurl;
$t->data['logouturl'] = $logouturl;
$t->data['header'] = $t->getTranslator()->t('{core:frontpage:page_title}');
$t->data['links'] = $links;
......
......@@ -10,7 +10,7 @@ if ($config->getBoolean('admin.protectindexpage', false)) {
}
$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
$warnings = array();
......@@ -168,6 +168,7 @@ $t->data['pageid'] = 'frontpage_config';
$t->data['header'] = $translator->t('{core:frontpage:page_title}');
$t->data['isadmin'] = $isadmin;
$t->data['loginurl'] = $loginurl;
$t->data['logouturl'] = $logouturl;
foreach ($warnings as &$warning) {
if (is_array($warning)) {
......
......@@ -8,6 +8,7 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
if ($config->getBoolean('admin.protectindexpage', false)) {
\SimpleSAML\Utils\Auth::requireAdmin();
}
$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
......@@ -158,7 +159,7 @@ $mtype = array(
$t->data['pageid'] = 'frontpage_federation';
$t->data['isadmin'] = $isadmin;
$t->data['loginurl'] = $loginurl;
$t->data['logouturl'] = $logouturl;
$t->data['links'] = $links;
$t->data['links_welcome'] = $links_welcome;
......
......@@ -8,6 +8,7 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
if ($config->getBoolean('admin.protectindexpage', false)) {
SimpleSAML\Utils\Auth::requireAdmin();
}
$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL();
$isadmin = \SimpleSAML\Utils\Auth::isAdmin();
......@@ -36,6 +37,7 @@ $t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_welcome.tpl.php');
$t->data['pageid'] = 'frontpage_welcome';
$t->data['isadmin'] = $isadmin;
$t->data['loginurl'] = $loginurl;
$t->data['logouturl'] = $logouturl;
$t->data['links'] = $links;
$t->data['links_welcome'] = $links_welcome;
......
......@@ -6,6 +6,7 @@
<li class="ui-state-default ui-corner-top"><a href="/{{ baseurlpath }}module.php/core/frontpage_auth.php">Authentication</a></li>
<li class="ui-state-default ui-corner-top"><a href="/{{ baseurlpath }}module.php/core/frontpage_federation.php">Federation</a></li>
</ul>
<a class='float-r' href='{{ logouturl }}'>{{ '{core:frontpage:logout}'|trans }}</a>
<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
<div style="clear: both" class="enablebox mini">
......
......@@ -16,12 +16,14 @@ $adminpages = array(
'sandbox.php' => 'Sandbox for testing changes to layout and css',
);
$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
$template = new \SimpleSAML\XHTML\Template($config, 'index.php');
$template->data['pagetitle'] = 'Admin';
$template->data['adminpages'] = $adminpages;
$template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time();
$template->data['valid'] = 'na';
$template->data['logout'] = null;
$template->data['logouturl'] = $logouturl;
$template->show();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment