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( SKIN => "$skin" );
$template->param( AUTH_ERROR => $portal->error ); $template->param( AUTH_ERROR => $portal->error );
$template->param( AUTH_ERROR_TYPE => $portal->error_type ); $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 # Display form the first time
$template->param( DISPLAY_FORM => 1 ) $template->param( DISPLAY_FORM => 1 )

View File

@ -10,6 +10,7 @@
<TMPL_IF NAME="DISPLAY_FORM"> <TMPL_IF NAME="DISPLAY_FORM">
<p class="text-error"><TMPL_VAR NAME="AUTH_ERROR"></p> <p class="text-error"><TMPL_VAR NAME="AUTH_ERROR"></p>
<form action="#" method="post" class="login"> <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"> <div id="content-all-info">
<table> <table>
<tr> <tr>

View File

@ -19,7 +19,7 @@
<TMPL_IF NAME="DISPLAY_RESETPASSWORD"> <TMPL_IF NAME="DISPLAY_RESETPASSWORD">
<p> <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> </p>
</TMPL_IF> </TMPL_IF>

View File

@ -10,6 +10,8 @@
<form action="#" method="post" class="login"> <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> <h3><lang en="Forgot your password?" fr="Mot de passe oubli&eacute; ?"/></h3>
<table> <table>

View File

@ -21,10 +21,10 @@
<TMPL_IF NAME="DISPLAY_RESETPASSWORD"> <TMPL_IF NAME="DISPLAY_RESETPASSWORD">
<tr><td colspan="2"> <tr><td colspan="2">
<div class="buttons"> <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="" /> <img src="/skins/common/email.png" alt="" />
<lang en="Reset my password" fr="R&eacute;initialiser mon mot de passe"/> <lang en="Reset my password" fr="R&eacute;initialiser mon mot de passe"/>
</button> </a>
</div></td></tr> </div></td></tr>
</TMPL_IF> </TMPL_IF>
</table> </table>

View File

@ -11,7 +11,7 @@ use Lemonldap::NG::Portal::Simple;
#inherits Lemonldap::NG::Portal::_Choice #inherits Lemonldap::NG::Portal::_Choice
our $VERSION = '1.0.0'; our $VERSION = '1.0.2';
## @apmethod int authInit() ## @apmethod int authInit()
# Build authentication loop # Build authentication loop
@ -23,20 +23,6 @@ sub authInit {
# Build authLoop # Build authLoop
$self->{authLoop} = $self->_buildAuthLoop(); $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 ); return $self->_choice->try( 'authInit', 0 );
} }

View File

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

View File

@ -8,7 +8,7 @@ package Lemonldap::NG::Portal::_Choice;
use Lemonldap::NG::Portal::Simple; 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) ## @cmethod Lemonldap::NG::Portal::_Choice new(Lemonldap::NG::Portal::Simple portal)
# Constructor # Constructor
@ -131,7 +131,24 @@ package Lemonldap::NG::Portal::Simple;
# @return Lemonldap::NG::Portal::_Choice object # @return Lemonldap::NG::Portal::_Choice object
sub _choice { sub _choice {
my $self = shift; my $self = shift;
# Check if choice is already built
return $self->{_choice} if ( $self->{_choice} ); 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); return $self->{_choice} = Lemonldap::NG::Portal::_Choice->new($self);
} }