Support AuthChoice for reset password feature (#269)

This commit is contained in:
Clément Oudot 2011-01-25 10:57:45 +00:00
parent 7901a2e894
commit 5b1a1c73d0
8 changed files with 30 additions and 20 deletions

View File

@ -26,6 +26,8 @@ $template->param( PORTAL_URL => "$portal_url" );
$template->param( SKIN => "$skin" );
$template->param( AUTH_ERROR => $portal->error );
$template->param( AUTH_ERROR_TYPE => $portal->error_type );
$template->param( CHOICE_PARAM => $portal->{authChoiceParam} );
$template->param( CHOICE_VALUE => $portal->{_authChoice} );
# Display form the first time
$template->param( DISPLAY_FORM => 1 )

View File

@ -10,6 +10,7 @@
<TMPL_IF NAME="DISPLAY_FORM">
<p class="text-error"><TMPL_VAR NAME="AUTH_ERROR"></p>
<form action="#" method="post" class="login">
<input type="hidden" id="authKey" name="<TMPL_VAR NAME="CHOICE_PARAM">" value="<TMPL_VAR NAME="CHOICE_VALUE">" />
<div id="content-all-info">
<table>
<tr>

View File

@ -19,7 +19,7 @@
<TMPL_IF NAME="DISPLAY_RESETPASSWORD">
<p>
<img src="/skins/<TMPL_VAR NAME="SKIN">/images/arrow.png" /><a href="<TMPL_VAR NAME="MAIL_URL">"><lang en="Reset my password" fr="R&eacute;initialiser mon mot de passe"/></a>
<img src="/skins/<TMPL_VAR NAME="SKIN">/images/arrow.png" /><a href="<TMPL_VAR NAME="MAIL_URL"><TMPL_IF NAME="key">?<TMPL_VAR NAME="CHOICE_PARAM">=<TMPL_VAR NAME="key"></TMPL_IF>"><lang en="Reset my password" fr="R&eacute;initialiser mon mot de passe"/></a>
</p>
</TMPL_IF>

View File

@ -10,6 +10,8 @@
<form action="#" method="post" class="login">
<input type="hidden" id="authKey" name="<TMPL_VAR NAME="CHOICE_PARAM">" value="<TMPL_VAR NAME="CHOICE_VALUE">" />
<h3><lang en="Forgot your password?" fr="Mot de passe oubli&eacute; ?"/></h3>
<table>

View File

@ -21,10 +21,10 @@
<TMPL_IF NAME="DISPLAY_RESETPASSWORD">
<tr><td colspan="2">
<div class="buttons">
<button class="positive" tabindex="5" onclick="$(location).attr('href','<TMPL_VAR NAME="MAIL_URL">');return false">
<a class="positive" tabindex="5" href="<TMPL_VAR NAME="MAIL_URL"><TMPL_IF NAME="key">?<TMPL_VAR NAME="CHOICE_PARAM">=<TMPL_VAR NAME="key"></TMPL_IF>">
<img src="/skins/common/email.png" alt="" />
<lang en="Reset my password" fr="R&eacute;initialiser mon mot de passe"/>
</button>
</a>
</div></td></tr>
</TMPL_IF>
</table>

View File

@ -11,7 +11,7 @@ use Lemonldap::NG::Portal::Simple;
#inherits Lemonldap::NG::Portal::_Choice
our $VERSION = '1.0.0';
our $VERSION = '1.0.2';
## @apmethod int authInit()
# Build authentication loop
@ -23,20 +23,6 @@ sub authInit {
# Build authLoop
$self->{authLoop} = $self->_buildAuthLoop();
# Get authentication choice
$self->{_authChoice} = $self->param( $self->{authChoiceParam} );
# Check XSS Attack
$self->{_authChoice} = ""
if ( $self->{_authChoice}
and
$self->checkXSSAttack( $self->{authChoiceParam}, $self->{_authChoice} )
);
$self->lmLog( "Authentication choice found: " . $self->{_authChoice},
'debug' )
if $self->{_authChoice};
return $self->_choice->try( 'authInit', 0 );
}

View File

@ -8,7 +8,7 @@ package Lemonldap::NG::Portal::MailReset;
use strict;
use warnings;
our $VERSION = '1.0.0';
our $VERSION = '1.0.2';
use Lemonldap::NG::Portal::Simple qw(:all);
use base qw(Lemonldap::NG::Portal::SharedConf Exporter);
@ -152,6 +152,8 @@ sub sendConfirmationMail {
# Build confirmation url
my $url = $self->{mailUrl} . "?mail_token=" . $self->{id};
$url .= '&' . $self->{authChoiceParam} . '=' . $self->{_authChoice}
if ( $self->{_authChoice} );
# Build mail content
my $subject = $self->{mailConfirmSubject};

View File

@ -8,7 +8,7 @@ package Lemonldap::NG::Portal::_Choice;
use Lemonldap::NG::Portal::Simple;
our $VERSION = '1.0.0';
our $VERSION = '1.0.2';
## @cmethod Lemonldap::NG::Portal::_Choice new(Lemonldap::NG::Portal::Simple portal)
# Constructor
@ -131,7 +131,24 @@ package Lemonldap::NG::Portal::Simple;
# @return Lemonldap::NG::Portal::_Choice object
sub _choice {
my $self = shift;
# Check if choice is already built
return $self->{_choice} if ( $self->{_choice} );
# Get authentication choice
$self->{_authChoice} = $self->param( $self->{authChoiceParam} );
# Check XSS Attack
$self->{_authChoice} = ""
if ( $self->{_authChoice}
and
$self->checkXSSAttack( $self->{authChoiceParam}, $self->{_authChoice} )
);
$self->lmLog( "Authentication choice found: " . $self->{_authChoice},
'debug' )
if $self->{_authChoice};
return $self->{_choice} = Lemonldap::NG::Portal::_Choice->new($self);
}