mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-04-26 06:20:08 +02:00
add a combobox instead of buttons to select the login method if more then 4 different IDPs are configured
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
bd63790118
commit
fadb3a1e4a
8
js/selectUserBackEnd.js
Normal file
8
js/selectUserBackEnd.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
$(window).load(function() {
|
||||
|
||||
$(document).on('click', 'option', function() {
|
||||
var target = $(this).val();
|
||||
window.location.href = target;
|
||||
});
|
||||
|
||||
});
|
|
@ -366,18 +366,21 @@ class SAMLController extends Controller {
|
|||
*/
|
||||
public function selectUserBackEnd($redirectUrl) {
|
||||
|
||||
$loginUrls = [];
|
||||
$attributes = ['loginUrls' => []];
|
||||
|
||||
if ($this->SAMLSettings->allowMultipleUserBackEnds()) {
|
||||
$loginUrls['directLogin'] = [
|
||||
$attributes['loginUrls']['directLogin'] = [
|
||||
'url' => $this->getDirectLoginUrl($redirectUrl),
|
||||
'display-name' => $this->l->t('Direct log in')
|
||||
];
|
||||
}
|
||||
|
||||
$loginUrls['ssoLogin'] = $this->getIdps($redirectUrl);
|
||||
$attributes['loginUrls']['ssoLogin'] = $this->getIdps($redirectUrl);
|
||||
|
||||
return new Http\TemplateResponse($this->appName, 'selectUserBackEnd', $loginUrls, 'guest');
|
||||
$attributes['useCombobox'] = count($attributes['loginUrls']['ssoLogin']) > 4 ? true : false;
|
||||
|
||||
|
||||
return new Http\TemplateResponse($this->appName, 'selectUserBackEnd', $attributes, 'guest');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
style('user_saml', 'selectUserBackEnd');
|
||||
script('user_saml', 'selectUserBackEnd');
|
||||
|
||||
/** @var array $_ */
|
||||
/** @var $l \OCP\IL10N */
|
||||
|
@ -9,16 +10,31 @@ style('user_saml', 'selectUserBackEnd');
|
|||
|
||||
<h1>Choose login option:</h1>
|
||||
|
||||
<?php if(isset($_['directLogin'])) : ?>
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['directLogin']['url']); ?>"><?php p($_['directLogin']['display-name']); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if($_['useCombobox']) { ?>
|
||||
|
||||
<select id="av_mode" name="avMode">
|
||||
<?php foreach ($_['loginUrls']['ssoLogin'] as $idp) { ?>
|
||||
<option value="<?php p($idp['url']); ?>"><?php p($idp['display-name']); ?></option>
|
||||
<?php } ?>
|
||||
<?php if(isset($_['loginUrls']['directLogin'])) : ?>
|
||||
<option value="<?php p($_['loginUrls']['directLogin']['url']); ?>"><?php p($_['loginUrls']['directLogin']['display-name']); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if(isset($_['loginUrls']['directLogin'])) : ?>
|
||||
<div class="login-option">
|
||||
<a href="<?php p($_['loginUrls']['directLogin']['url']); ?>"><?php p($_['loginUrls']['directLogin']['display-name']); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($_['loginUrls']['ssoLogin'] as $idp) { ?>
|
||||
<div class="login-option">
|
||||
<a href="<?php p($idp['url']); ?>"><?php p($idp['display-name']); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php foreach ($_['ssoLogin'] as $idp) { ?>
|
||||
<div class="login-option">
|
||||
<a href="<?php p($idp['url']); ?>"><?php p($idp['display-name']); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue