Skip to content
Snippets Groups Projects
Commit b6f28f4f authored by Tim van Dijen's avatar Tim van Dijen
Browse files

authYubiKey: move to Twig-template

parent 072918f8
No related branches found
No related tags found
No related merge requests found
{% set pagetitle = '{authYubiKey:yubikey:header}'|trans %}
{% extends "base.twig" %}
{% block content %}
{% if errorCode != null %}
<div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5">
<img src="{{ baseurlpath }}resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px;" alt="" />
<h2>{{ '{login:error_header}'|trans }}</h2>
<p><span style="text-decoration: bold;">{{ errorTitle }}</p>
<p>{{ errorDesc }}</p>
</div>
{% endif %}
<img style="float: right" src="{{ logoUrl }}" alt="" />
<img style="clear: right; float: right" src="{{ devicepicUrl }}" alt="YubiKey" />
<h2>{{ '{authYubiKey:yubikey:header}'|trans }}</h2>
<form action="?" method="post" name="f">
<p>{{ '{authYubiKey:yubikey:intro}'|trans }}</p>
<p><input id="otp" style="border: 1px solid #ccc; background: #eee; padding: .5em; font-size: medium; width: 70%; color: #aaa" type="text" tabindex="2" name="otp" /></p>
{% for key, value in stateParams %}
<input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}"/>
{% endfor %}
</form>
{% endblock %}
...@@ -12,27 +12,22 @@ ...@@ -12,27 +12,22 @@
if (!array_key_exists('AuthState', $_REQUEST)) { if (!array_key_exists('AuthState', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.'); throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
} }
$authStateId = $_REQUEST['AuthState'];
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'authYubiKey:yubikeylogin.php');
$errorCode = null;
if (array_key_exists('otp', $_REQUEST)) { if (array_key_exists('otp', $_REQUEST)) {
$otp = $_REQUEST['otp']; // attempt to log in
} else { $errorCode = sspmod_authYubiKey_Auth_Source_YubiKey::handleLogin($authStateId, $_REQUEST['otp']);
$otp = '';
}
if (!empty($otp)) { $errorCodes = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
// attempt to log in $t->data['errorTitle'] = $errorCodes['title'][$errorCode];
$errorCode = sspmod_authYubiKey_Auth_Source_YubiKey::handleLogin($authStateId, $otp); $t->data['errorDesc'] = $errorCodes['desc'][$errorCode];
} else {
$errorCode = NULL;
} }
$globalConfig = SimpleSAML_Configuration::getInstance(); $t->data['errorCode'] = $errorCode;
$t = new SimpleSAML_XHTML_Template($globalConfig, 'authYubiKey:yubikeylogin.php'); $t->data['stateParams'] = array('AuthState' => $_REQUEST['authStateId']);
$t->data['stateparams'] = array('AuthState' => $authStateId); $t->data['logoUrl'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/logo.jpg');
$t->data['errorcode'] = $errorCode; $t->data['devicepicUrl'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/yubikey.jpg');
$t->data['errorcodes'] = SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages();
$t->data['logo_url'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/logo.jpg');
$t->data['devicepic_url'] = SimpleSAML\Module::getModuleURL('authYubiKey/resources/yubikey.jpg');
$t->show(); $t->show();
exit();
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