Skip to content
Snippets Groups Projects
Commit 4048d4a8 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Adding support for adding links to login page in authsources.php

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2228 44740490-163a-0410-bde0-09ae8108e29a
parent 7da29db3
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,12 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
* If this is NULL, we won't force any username.
*/
private $forcedUsername;
/**
* Links to pages from login page.
* From configuration
*/
protected $loginLinks;
/**
......@@ -46,6 +52,10 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
public function __construct($info, &$config) {
assert('is_array($info)');
assert('is_array($config)');
if (isset($config['core:loginpage_links'])) {
$this->loginLinks = $config['core:loginpage_links'];
}
/* Call the parent constructor first, as required by the interface. */
parent::__construct($info, $config);
......@@ -62,6 +72,13 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
$this->forcedUsername = $forcedUsername;
}
/**
* Return login links from configuration
*/
public function getLoginLinks() {
return $this->loginLinks;
}
/**
* Initialize login.
......
......@@ -93,6 +93,18 @@ foreach ($this->data['stateparams'] as $name => $value) {
</form>
<?php
if(!empty($this->data['links'])) {
echo '<ul class="links" style="margin-top: 2em">';
foreach($this->data['links'] AS $l) {
echo '<li><a href="' . htmlspecialchars($l['href']) . '">' . htmlspecialchars($this->t($l['text'])) . '</a></li>';
}
echo '</ul>';
}
echo('<h2>' . $this->t('{login:help_header}') . '</h2>');
echo('<p>' . $this->t('{login:help_text}') . '</p>');
......
......@@ -18,6 +18,13 @@ $authStateId = $_REQUEST['AuthState'];
/* Retrieve the authentication state. */
$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_core_Auth_UserPassBase::STAGEID);
$source = SimpleSAML_Auth_Source::getById($state[sspmod_core_Auth_UserPassBase::AUTHID]);
if ($source === NULL) {
throw new Exception('Could not find authentication source with id ' . $state[sspmod_core_Auth_UserPassBase::AUTHID]);
}
if (array_key_exists('username', $_REQUEST)) {
$username = $_REQUEST['username'];
} elseif (isset($state['core:username'])) {
......@@ -54,6 +61,7 @@ if (array_key_exists('forcedUsername', $state)) {
$t->data['username'] = $username;
$t->data['forceUsername'] = FALSE;
}
$t->data['links'] = $source->getLoginLinks();
$t->data['errorcode'] = $errorCode;
$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