IdP choice : replace radio button with submit button (Lemonldap-428)

This commit is contained in:
François-Xavier Deltombe 2012-02-15 15:28:08 +00:00
parent c4bf8af37a
commit 521d171109
3 changed files with 53 additions and 67 deletions

View File

@ -7,6 +7,9 @@
<div class="loginlogo"></div>
<form id="form" action="#" method="<TMPL_VAR NAME="FORM_METHOD">" class="login">
<TMPL_VAR NAME="MSG">
<TMPL_VAR NAME="HIDDEN_INPUTS">
<TMPL_IF NAME="AUTH_URL">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
@ -17,8 +20,48 @@
<TMPL_IF NAME="CONFIRMKEY">
<input type="hidden" id="confirm" name="confirm" value="<TMPL_VAR NAME="CONFIRMKEY">" />
</TMPL_IF>
<TMPL_VAR NAME="MSG">
<TMPL_IF NAME="LIST">
<h3><lang en="Select your Identity Provider" fr="Choisissez votre fournisseur d'identité"/></h3>
<input type="hidden" id="idp" name="idp"/>
<table>
<TMPL_LOOP NAME="LIST">
<tr><td><div class="buttons">
<button type="submit" class="positive" style="width: 100%" onclick="$('#idp').val('<TMPL_VAR NAME="VAL">')">
<TMPL_VAR NAME="NAME">
</button>
</div></td></tr>
</TMPL_LOOP>
<tr>
<td><input type="checkbox" id="remember" name="cookie_type" value="1"><label for="remember"><lang en="Remember my choice" fr="Se souvenir de mon choix"/></label></td>
</tr>
</table>
<TMPL_ELSE>
<TMPL_IF NAME="ACTIVE_TIMER">
<p id="timer"><lang en="Automatically accept in 5 seconds" fr="Acceptation automatique dans 5 secondes"/></p>
<script>
var i=5;
function go() {
$("#form").submit();
}
function timer() {
var h=$('#timer').html();
if(i>0){i--;}
h=h.replace(/\d+/,i);
$('#timer').html(h);
window.setTimeout('timer()',1000);
}
$(document).ready(function(){
window.setTimeout('go()',5000);
window.setTimeout('timer()',1000);
});
</script>
</TMPL_IF>
<table><tbody><tr><td>
<div class="buttons">
<button type="submit" class="positive">
@ -31,37 +74,9 @@
</button>
</div>
</td></tr></tbody></table>
</form>
<script>
var i=5;
var _go=1;
function stop() {
_go=0;
$('#timer').html("...");
}
function go() {
if(_go)$("#form").submit();
}
function timer() {
var h=$('#timer').html();
if(i>0){i--;}
h=h.replace(/\d+/,i);
$('#timer').html(h);
window.setTimeout('timer()',1000);
}
$(document).ready(function(){
// Check if timer should be activated (true by default)
var activeTimer = true;
if (!<TMPL_VAR NAME="ACTIVE_TIMER">) {activeTimer = false;}
if (activeTimer) {
window.setTimeout('go()',5000);
window.setTimeout('timer()',1000);
} else {
stop();
}
});
</script>
</TMPL_IF>
</form>
</div>

View File

@ -773,14 +773,6 @@ sub extractFormInfo {
# Get confirmation flag
my $confirm_flag = $self->param("confirm");
# If confirmation is -1 from IDP list,
# return error to get next authentication method
# with AuthMulti
if ( $confirm_flag == -1 and $self->param("idplist") ) {
$self->lmLog( "SAML authentication refused by user", 'error' );
return PE_ERROR;
}
# If confirmation is -1 from resolved IDP screen,
# or IDP was not resolve, let the user choose its IDP
if ( $confirm_flag == -1 or !$idp ) {
@ -791,36 +783,14 @@ sub extractFormInfo {
return $urlcheck unless ( $urlcheck == PE_OK );
# IDP list
my $html = "<h3>" . $self->msg(PM_SAML_IDPSELECT) . "</h3>\n<table>\n";
my @list = ();
foreach ( keys %{ $self->{_idpList} } ) {
$html .=
'<tr><td><input type="radio" name="idp" value="'
. $_
. '" /></td><td>'
. $self->{_idpList}->{$_}->{name}
. '</td></tr>';
push @list, {
val => $_,
name => $self->{_idpList}->{$_}->{name}
};
}
$html .=
'<tr><td><input type="checkbox" name="cookie_type" value="1"></td><td>'
. $self->msg(PM_REMEMBERCHOICE)
. "</td></tr></table>\n"
# URL
. '<input type="hidden" name="url" value="'
. $self->param("url") . '" />'
# IDP list flag
. '<input type="hidden" name="idplist" value="1" />'
# Script to autoselect first choice
. '<script>$("[type=radio]:first").attr("checked","checked");</script>';
$self->info($html);
# Timer not active on IDP list
$self->{activeTimer} = 0;
$self->{list} = \@list;
# Delete existing IDP resolution cookie
push @{ $self->{cookie} },

View File

@ -142,6 +142,7 @@ sub display {
CHOICE_PARAM => $self->{authChoiceParam},
CHOICE_VALUE => $self->{_authChoice},
CONFIRMKEY => $self->stamp(),
LIST => $self->{list} || [],
);
}