change to www_ methods everywhere

This commit is contained in:
Doug Bell 2010-11-03 18:02:49 -05:00
parent 26853527a0
commit 5a2d4d8d03
7 changed files with 1165 additions and 1096 deletions

View file

@ -22,6 +22,7 @@ use WebGUI::Storage;
use WebGUI::User;
use WebGUI::Form::Captcha;
use WebGUI::Macro;
use WebGUI::Deprecate;
use Encode ();
use Tie::IxHash;
@ -130,203 +131,6 @@ sub authenticate {
return 0;
}
#-------------------------------------------------------------------
sub createAccount {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $setting = $session->setting;
my $message = shift;
my $confirm = shift || $form->process("confirm");
my $vars = shift || {};
my $i18n = WebGUI::International->new($session);
if ($self->session->user->isRegistered) {
return $self->displayAccount;
}
elsif (!$setting->get("anonymousRegistration") && !$setting->get('inboxInviteUserEnabled')) {
return $self->displayLogin;
}
$vars->{'create.message'} = '<ul>'.$message.'</ul>' if ($message);
$vars->{'useCaptcha' } = $setting->get("webguiUseCaptcha");
if ($vars->{useCaptcha}) {
use WebGUI::Form::Captcha;
my $captcha = WebGUI::Form::Captcha->new($session,{
name => "authWebGUI.captcha",
extras => $self->getExtrasStyle
});
$vars->{'create.form.captcha'}
= $captcha->toHtml . '<span class="formSubtext">' . $captcha->get('subtext').'</span>';
$vars->{'create.form.captcha.label'} = $i18n->get("captcha label","AuthWebGUI");
}
unless($setting->get('webguiUseEmailAsUsername')){
my $username = $form->process("authWebGUI.username");
$vars->{'create.form.username'}
= WebGUI::Form::username($self->session, {
name => "authWebGUI.username",
value => $username,
extras => $self->getExtrasStyle($username)
});
$vars->{'create.form.username.label'} = $i18n->get(50);
}
my $password = $form->process("authWebGUI.identifier");
$vars->{'create.form.password'}
= WebGUI::Form::password($self->session, {
name => "authWebGUI.identifier",
value => $password,
extras => $self->getExtrasStyle($password)
});
$vars->{'create.form.password.label'} = $i18n->get(51);
my $passwordConfirm = $form->process("authWebGUI.identifierConfirm");
$vars->{'create.form.passwordConfirm'}
= WebGUI::Form::password($self->session, {
name => "authWebGUI.identifierConfirm",
value => $passwordConfirm,
extras => $self->getExtrasStyle($passwordConfirm)
});
$vars->{'create.form.passwordConfirm.label'} = $i18n->get(2,'AuthWebGUI');
$vars->{'create.form.hidden'}
= WebGUI::Form::hidden($self->session, {
"name" => "confirm",
"value" => $confirm
});
$vars->{'recoverPassword.isAllowed' } = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url' } = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label' } = $i18n->get(59);
return $self->SUPER::createAccount("createAccountSave",$vars);
}
#-------------------------------------------------------------------
sub createAccountSave {
my $self = shift;
my $session = $self->session;
my $form = $self->session->form;
my $setting = $self->session->setting;
my $i18n = WebGUI::International->new($session);
# Logged in users cannot see this page
return $self->displayAccount if ($session->user->isRegistered);
# Make sure anonymous registration is enabled
if (!$setting->get("anonymousRegistration") && !$setting->get("inboxInviteUserEnabled")) {
$session->log->security($i18n->get("no registration hack", "AuthWebGUI"));
return $self->displayLogin;
}
my $username;
if($setting->get('webguiUseEmailAsUsername')){
$username = $form->process('email');
}
else{
$username = $form->process('authWebGUI.username');
}
my $password = $form->process('authWebGUI.identifier');
my $passConfirm = $form->process('authWebGUI.identifierConfirm');
# Validate input
my $error;
$error = $self->error unless($self->validUsername($username));
if ($setting->get("webguiUseCaptcha")) {
my $form = WebGUI::Form::Captcha->new($session, {name => 'authWebGUI.captcha'});
if (! $form->getValue) {
$error .= '<li>' . $form->getErrorMessage . '</li>';
}
}
$error .= $self->error unless($self->_isValidPassword($password,$passConfirm));
my $fields = WebGUI::ProfileField->getRegistrationFields($session);
my $retHash = $self->user->validateProfileDataFromForm($fields);
my $profile = $retHash->{profile};
my $temp = "";
my $warning = "";
my $format = "<li>%s</li>";
map { $warning .= sprintf($format,$_) } @{$retHash->{warnings}};
map { $temp .= sprintf($format,$_) } @{$retHash->{errors}};
$error .= $temp;
unless ($error eq "") {
$self->error($error);
return $self->createAccount($error);
}
# If Email address is not unique, a warning is displayed
if ($warning ne "" && !$self->session->form->process("confirm")) {
return $self->createAccount('<li>'.$i18n->get(1078).'</li>', 1);
}
# Create the new account
my $properties;
$properties->{ changeUsername } = $setting->get("webguiChangeUsername");
$properties->{ changePassword } = $setting->get("webguiChangePassword");
$properties->{ identifier } = $self->hashPassword($password);
$properties->{ passwordLastUpdated } = time();
$properties->{ passwordTimeout } = $setting->get("webguiPasswordTimeout");
$properties->{ status } = 'Deactivated' if ($setting->get("webguiValidateEmail"));
my $afterCreateMessage = $self->SUPER::createAccountSave($username,$properties,$password,$profile);
# Send validation e-mail if required
if ($setting->get("webguiValidateEmail")) {
my $key = $session->id->generate;
$self->update(emailValidationKey=>$key);
my $mail = WebGUI::Mail::Send->create($self->session, {
to => $profile->{email},
subject => $i18n->get('email address validation email subject','AuthWebGUI')
});
my $var;
$var->{newUser_username} = $username;
$var->{activationUrl} = $session->url->page("op=auth;method=validateEmail;key=".$key, 'full');
my $text =
WebGUI::Asset::Template->newById($self->session,$self->getSetting('accountActivationTemplate'))->process($var);
WebGUI::Macro::process($self->session,\$text);
$mail->addText($text);
$mail->addFooter;
$mail->queue;
$self->user->status("Deactivated");
$session->var->end($session->var->get("sessionId"));
$session->var->start(1,$session->getId);
my $u = WebGUI::User->new($session,1);
$self->{user} = $u;
$self->logout;
return $self->displayLogin($i18n->get('check email for validation','AuthWebGUI'));
}
return $afterCreateMessage;
}
#-------------------------------------------------------------------
sub deactivateAccount {
my $self = shift;
return $self->displayLogin if($self->isVisitor);
return $self->SUPER::deactivateAccount("deactivateAccountConfirm");
}
#-------------------------------------------------------------------
sub deactivateAccountConfirm {
my $self = shift;
return $self->displayLogin unless ($self->session->setting->get("selfDeactivation"));
# Keep the username for a nice message
my $username = $self->user->username;
# Deactivate the account
my $response = $self->SUPER::deactivateAccountConfirm;
# If there was a response, it's probably an error
return $response if $response;
# Otherwise show the login form with a friendly message
my $i18n = WebGUI::International->new($self->session);
return $self->displayLogin(sprintf( $i18n->get("deactivateAccount success"), $username ));
}
#-------------------------------------------------------------------
=head2 checkField ( )
@ -339,51 +143,6 @@ or an empty string if the check was successful.
=cut
#-------------------------------------------------------------------
sub displayAccount {
my $self = shift;
my $vars;
return $self->displayLogin($_[0]) if ($self->isVisitor);
my $i18n = WebGUI::International->new($self->session);
my $userData = $self->get;
$vars->{'account.message'} = $_[0] if ($_[0]);
$vars->{'account.noform'} = 1;
if($userData->{changeUsername} || (!defined $userData->{changeUsername} && $self->session->setting->get("webguiChangeUsername"))){
$vars->{'account.form.username'} = WebGUI::Form::text($self->session,{"name"=>"authWebGUI.username","value"=>$self->username});
$vars->{'account.form.username.label'} = $i18n->get(50);
$vars->{'account.noform'} = 0;
}
if($userData->{changePassword} || (!defined $userData->{changePassword} && $self->session->setting->get("webguiChangePassword"))){
$vars->{'account.form.password'} = WebGUI::Form::password($self->session,{"name"=>"authWebGUI.identifier","value"=>"password"});
$vars->{'account.form.password.label'} = $i18n->get(51);
$vars->{'account.form.passwordConfirm'} = WebGUI::Form::password($self->session,{"name"=>"authWebGUI.identifierConfirm","value"=>"password"});
$vars->{'account.form.passwordConfirm.label'} = $i18n->get(2,'AuthWebGUI');
$vars->{'account.noform'} = 0;
}
$vars->{'account.nofields'} = $i18n->get(22,'AuthWebGUI');
return $self->SUPER::displayAccount("updateAccount",$vars);
}
#-------------------------------------------------------------------
=head2 displayLogin ( )
The initial login screen an unauthenticated user sees
=cut
sub displayLogin {
my $self = shift;
my $vars;
return $self->displayAccount($_[0]) if ($self->isRegistered);
my $i18n = WebGUI::International->new($self->session);
$vars->{'login.message'} = '<ul>'.$_[0].'</ul>' if ($_[0]);
$vars->{'recoverPassword.isAllowed'} = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url'} = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label'} = $i18n->get(59);
return $self->SUPER::displayLogin("login",$vars);
}
#-------------------------------------------------------------------
=head2 editUserForm ( )
@ -781,15 +540,257 @@ sub hashPassword {
return Digest::MD5::md5_base64(Encode::encode_utf8($password));
}
#-------------------------------------------------------------------
sub www_createAccount {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $setting = $session->setting;
my $message = shift;
my $confirm = shift || $form->process("confirm");
my $vars = shift || {};
my $i18n = WebGUI::International->new($session);
if ($self->session->user->isRegistered) {
return $self->www_displayAccount;
}
elsif (!$setting->get("anonymousRegistration") && !$setting->get('inboxInviteUserEnabled')) {
return $self->www_displayLogin;
}
$vars->{'create.message'} = '<ul>'.$message.'</ul>' if ($message);
$vars->{'useCaptcha' } = $setting->get("webguiUseCaptcha");
if ($vars->{useCaptcha}) {
use WebGUI::Form::Captcha;
my $captcha = WebGUI::Form::Captcha->new($session,{
name => "authWebGUI.captcha",
extras => $self->getExtrasStyle
});
$vars->{'create.form.captcha'}
= $captcha->toHtml . '<span class="formSubtext">' . $captcha->get('subtext').'</span>';
$vars->{'create.form.captcha.label'} = $i18n->get("captcha label","AuthWebGUI");
}
unless($setting->get('webguiUseEmailAsUsername')){
my $username = $form->process("authWebGUI.username");
$vars->{'create.form.username'}
= WebGUI::Form::username($self->session, {
name => "authWebGUI.username",
value => $username,
extras => $self->getExtrasStyle($username)
});
$vars->{'create.form.username.label'} = $i18n->get(50);
}
my $password = $form->process("authWebGUI.identifier");
$vars->{'create.form.password'}
= WebGUI::Form::password($self->session, {
name => "authWebGUI.identifier",
value => $password,
extras => $self->getExtrasStyle($password)
});
$vars->{'create.form.password.label'} = $i18n->get(51);
my $passwordConfirm = $form->process("authWebGUI.identifierConfirm");
$vars->{'create.form.passwordConfirm'}
= WebGUI::Form::password($self->session, {
name => "authWebGUI.identifierConfirm",
value => $passwordConfirm,
extras => $self->getExtrasStyle($passwordConfirm)
});
$vars->{'create.form.passwordConfirm.label'} = $i18n->get(2,'AuthWebGUI');
$vars->{'create.form.hidden'}
= WebGUI::Form::hidden($self->session, {
"name" => "confirm",
"value" => $confirm
});
$vars->{'recoverPassword.isAllowed' } = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url' } = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label' } = $i18n->get(59);
return $self->SUPER::www_createAccount("createAccountSave",$vars);
}
#-------------------------------------------------------------------
sub login {
sub www_createAccountSave {
my $self = shift;
my $session = $self->session;
my $form = $self->session->form;
my $setting = $self->session->setting;
my $i18n = WebGUI::International->new($session);
# Logged in users cannot see this page
return $self->www_displayAccount if ($session->user->isRegistered);
# Make sure anonymous registration is enabled
if (!$setting->get("anonymousRegistration") && !$setting->get("inboxInviteUserEnabled")) {
$session->log->security($i18n->get("no registration hack", "AuthWebGUI"));
return $self->www_displayLogin;
}
my $username;
if($setting->get('webguiUseEmailAsUsername')){
$username = $form->process('email');
}
else{
$username = $form->process('authWebGUI.username');
}
my $password = $form->process('authWebGUI.identifier');
my $passConfirm = $form->process('authWebGUI.identifierConfirm');
# Validate input
my $error;
$error = $self->error unless($self->validUsername($username));
if ($setting->get("webguiUseCaptcha")) {
my $form = WebGUI::Form::Captcha->new($session, {name => 'authWebGUI.captcha'});
if (! $form->getValue) {
$error .= '<li>' . $form->getErrorMessage . '</li>';
}
}
$error .= $self->error unless($self->_isValidPassword($password,$passConfirm));
my $fields = WebGUI::ProfileField->getRegistrationFields($session);
my $retHash = $self->user->validateProfileDataFromForm($fields);
my $profile = $retHash->{profile};
my $temp = "";
my $warning = "";
my $format = "<li>%s</li>";
map { $warning .= sprintf($format,$_) } @{$retHash->{warnings}};
map { $temp .= sprintf($format,$_) } @{$retHash->{errors}};
$error .= $temp;
unless ($error eq "") {
$self->error($error);
return $self->www_createAccount($error);
}
# If Email address is not unique, a warning is displayed
if ($warning ne "" && !$self->session->form->process("confirm")) {
return $self->www_createAccount('<li>'.$i18n->get(1078).'</li>', 1);
}
# Create the new account
my $properties;
$properties->{ changeUsername } = $setting->get("webguiChangeUsername");
$properties->{ changePassword } = $setting->get("webguiChangePassword");
$properties->{ identifier } = $self->hashPassword($password);
$properties->{ passwordLastUpdated } = time();
$properties->{ passwordTimeout } = $setting->get("webguiPasswordTimeout");
$properties->{ status } = 'Deactivated' if ($setting->get("webguiValidateEmail"));
my $afterCreateMessage = $self->SUPER::createAccountSave($username,$properties,$password,$profile);
# Send validation e-mail if required
if ($setting->get("webguiValidateEmail")) {
my $key = $session->id->generate;
$self->update(emailValidationKey=>$key);
my $mail = WebGUI::Mail::Send->create($self->session, {
to => $profile->{email},
subject => $i18n->get('email address validation email subject','AuthWebGUI')
});
my $var;
$var->{newUser_username} = $username;
$var->{activationUrl} = $session->url->page("op=auth;method=validateEmail;key=".$key, 'full');
my $text =
WebGUI::Asset::Template->newById($self->session,$self->getSetting('accountActivationTemplate'))->process($var);
WebGUI::Macro::process($self->session,\$text);
$mail->addText($text);
$mail->addFooter;
$mail->queue;
$self->user->status("Deactivated");
$session->var->end($session->var->get("sessionId"));
$session->var->start(1,$session->getId);
my $u = WebGUI::User->new($session,1);
$self->{user} = $u;
$self->logout;
return $self->www_displayLogin($i18n->get('check email for validation','AuthWebGUI'));
}
return $afterCreateMessage;
}
#-------------------------------------------------------------------
sub www_deactivateAccount {
my $self = shift;
return $self->www_displayLogin if($self->isVisitor);
return $self->SUPER::www_deactivateAccount("deactivateAccountConfirm");
}
#-------------------------------------------------------------------
sub www_deactivateAccountConfirm {
my $self = shift;
return $self->www_displayLogin unless ($self->session->setting->get("selfDeactivation"));
# Keep the username for a nice message
my $username = $self->user->username;
# Deactivate the account
my $response = $self->SUPER::www_deactivateAccountConfirm;
# If there was a response, it's probably an error
return $response if $response;
# Otherwise show the login form with a friendly message
my $i18n = WebGUI::International->new($self->session);
return $self->www_displayLogin(sprintf( $i18n->get("deactivateAccount success"), $username ));
}
#-------------------------------------------------------------------
sub www_displayAccount {
my $self = shift;
my $vars;
return $self->www_displayLogin($_[0]) if ($self->isVisitor);
my $i18n = WebGUI::International->new($self->session);
my $userData = $self->get;
$vars->{'account.message'} = $_[0] if ($_[0]);
$vars->{'account.noform'} = 1;
if($userData->{changeUsername} || (!defined $userData->{changeUsername} && $self->session->setting->get("webguiChangeUsername"))){
$vars->{'account.form.username'} = WebGUI::Form::text($self->session,{"name"=>"authWebGUI.username","value"=>$self->username});
$vars->{'account.form.username.label'} = $i18n->get(50);
$vars->{'account.noform'} = 0;
}
if($userData->{changePassword} || (!defined $userData->{changePassword} && $self->session->setting->get("webguiChangePassword"))){
$vars->{'account.form.password'} = WebGUI::Form::password($self->session,{"name"=>"authWebGUI.identifier","value"=>"password"});
$vars->{'account.form.password.label'} = $i18n->get(51);
$vars->{'account.form.passwordConfirm'} = WebGUI::Form::password($self->session,{"name"=>"authWebGUI.identifierConfirm","value"=>"password"});
$vars->{'account.form.passwordConfirm.label'} = $i18n->get(2,'AuthWebGUI');
$vars->{'account.noform'} = 0;
}
$vars->{'account.nofields'} = $i18n->get(22,'AuthWebGUI');
return $self->SUPER::www_displayAccount("updateAccount",$vars);
}
#-------------------------------------------------------------------
=head2 www_displayLogin ( )
The initial login screen an unauthenticated user sees
=cut
sub www_displayLogin {
my $self = shift;
my $vars;
print "WebGUI->www_displayLogin\n";
return $self->www_displayAccount($_[0]) if ($self->isRegistered);
my $i18n = WebGUI::International->new($self->session);
$vars->{'login.message'} = '<ul>'.$_[0].'</ul>' if ($_[0]);
$vars->{'recoverPassword.isAllowed'} = $self->getSetting("passwordRecovery");
$vars->{'recoverPassword.url'} = $self->session->url->page('op=auth;method=recoverPassword');
$vars->{'recoverPassword.label'} = $i18n->get(59);
return $self->SUPER::www_displayLogin("login",$vars);
}
#-------------------------------------------------------------------
sub www_login {
my $self = shift;
if(!$self->authenticate($self->session->form->process("username"),$self->session->form->process("identifier"))){
$self->session->http->setStatus(401);
$self->session->log->security("login to account ".$self->session->form->process("username")." with invalid information.");
my $i18n = WebGUI::International->new($self->session);
return $self->displayLogin("<h1>".$i18n->get(70)."</h1>".$self->error);
return $self->www_displayLogin("<h1>".$i18n->get(70)."</h1>".$self->error);
}
my $userData = $self->get;
@ -798,32 +799,16 @@ sub login {
if (time() >= $expireTime){
my $userId = $self->userId;
$self->logout;
return $self->resetExpiredPassword($userId);
return $self->www_resetExpiredPassword($userId);
}
}
return $self->SUPER::login();
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $session = shift;
my $userId = $_[0];
my $self = $class->SUPER::new($session,$userId);
$self->setCallable([
'validateEmail','createAccount','deactivateAccount','displayAccount',
'displayLogin','login','logout','recoverPassword','resetExpiredPassword',
'recoverPasswordFinish','createAccountSave','deactivateAccountConfirm',
'resetExpiredPasswordSave','updateAccount', 'emailResetPassword',
'emailResetPasswordFinish',
]);
return $self;
return $self->SUPER::www_login();
}
#-------------------------------------------------------------------
=head2 recoverPassword ( args )
=head2 www_recoverPassword ( args )
Initiates the password recovery process. Checks for recovery type,
and then runs the appropriate method. Arguments to this sub are
@ -831,24 +816,26 @@ passed directly to the approprate method.
=cut
sub recoverPassword {
sub www_recoverPassword {
my $self = shift;
return $self->displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
return $self->www_displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
my $type = $self->getPasswordRecoveryType;
if ($type eq 'profile') {
$self->profileRecoverPassword(@_);
$self->www_profileRecoverPassword(@_);
}
elsif ($type eq 'email') {
$self->emailRecoverPassword(@_);
$self->www_emailRecoverPassword(@_);
}
}
deprecate 'recoverPassword' => 'www_recoverPassword';
#-------------------------------------------------------------------
=head2 emailRecoverPassword ( $error )
=head2 www_emailRecoverPassword ( $error )
Templated email recovery form.
@ -858,7 +845,7 @@ $error is any error from the system which needs to be reported to the user.
=cut
sub emailRecoverPassword {
sub www_emailRecoverPassword {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session);
@ -902,14 +889,16 @@ sub emailRecoverPassword {
return WebGUI::Asset::Template->newById($self->session,$self->getPasswordRecoveryTemplateId)->process($vars);
}
deprecate 'emailRecoverPassword' => 'www_emailRecoverPassword';
#-------------------------------------------------------------------
sub profileRecoverPassword {
sub www_profileRecoverPassword {
my $self = shift;
my @fields = @{WebGUI::ProfileField->getPasswordRecoveryFields($self->session)};
return $self->displayLogin unless @fields;
return $self->www_displayLogin unless @fields;
my $vars = {};
my $i18n = WebGUI::International->new($self->session);
@ -947,10 +936,12 @@ sub profileRecoverPassword {
return WebGUI::Asset::Template->newById($self->session,$self->getPasswordRecoveryTemplateId)->process($vars);
}
deprecate 'profileRecoverPassword' => 'www_profileRecoverPassword';
#-------------------------------------------------------------------
=head2 recoverPasswordFinish ( args )
=head2 www_recoverPasswordFinish ( args )
Handles data for recovery of password. Gets password recovery type,
and then runs the appropriate method. Arguments are passed directly
@ -958,35 +949,37 @@ to the appropriate method.
=cut
sub recoverPasswordFinish {
sub www_recoverPasswordFinish {
my $self = shift;
my $type = $self->getPasswordRecoveryType;
if ($type eq 'profile') {
$self->profileRecoverPasswordFinish(@_);
$self->www_profileRecoverPasswordFinish(@_);
} elsif ($type eq 'email') {
$self->emailRecoverPasswordFinish(@_);
$self->www_emailRecoverPasswordFinish(@_);
}
}
}
deprecate 'recoverPasswordFinish' => 'www_recoverPasswordFinish';
#-------------------------------------------------------------------
sub profileRecoverPasswordFinish {
sub www_profileRecoverPasswordFinish {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($self->session);
my $i18n2 = WebGUI::International->new($self->session, 'AuthWebGUI');
return $self->displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
return $self->www_displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
my $username;
if ($self->getSetting('passwordRecoveryRequireUsername')) {
$username = $self->session->form->process('authWebGUI.username');
return $self->recoverPassword($i18n->get('password recovery no username', 'AuthWebGUI')) unless defined $username;
return $self->www_recoverPassword($i18n->get('password recovery no username', 'AuthWebGUI')) unless defined $username;
}
my @fields = @{WebGUI::ProfileField->getPasswordRecoveryFields($self->session)};
return $self->displayLogin unless @fields;
return $self->www_displayLogin unless @fields;
my %fieldValues;
my @failedRequiredFields;
@ -1000,7 +993,7 @@ sub profileRecoverPasswordFinish {
my $errorMessage = '<ul>' . join("\n", map {
'<li>' . $_->getLabel . ' ' . $i18n->get(451) . '</li>'
} @failedRequiredFields) . '</ul>';
return $self->recoverPassword($errorMessage);
return $self->www_recoverPassword($errorMessage);
}
my @fieldNames = keys %fieldValues;
@ -1011,10 +1004,10 @@ sub profileRecoverPasswordFinish {
my @userIds = $self->session->db->buildArray($sql, [$self->authMethod, @fieldValues, (defined($username)? ($username) : ())]);
if (@userIds == 0) {
return $self->recoverPassword($i18n2->get('password recovery no results'));
return $self->www_recoverPassword($i18n2->get('password recovery no results'));
}
elsif (@userIds > 1) {
return $self->recoverPassword($i18n2->get('password recovery multiple results'));
return $self->www_recoverPassword($i18n2->get('password recovery multiple results'));
}
# Exactly one result.
@ -1023,7 +1016,7 @@ sub profileRecoverPasswordFinish {
# Make sure the userId is not disabled
my $user = WebGUI::User->new($self->session, $userId);
if ( $user->status ne "Active" ) {
return $self->recoverPassword( $i18n2->get( 'password recovery disabled' ) );
return $self->www_recoverPassword( $i18n2->get( 'password recovery disabled' ) );
}
my ($password, $passwordConfirm) = ($self->session->form->process('authWebGUI.identifier'), $self->session->form->process('authWebGUI.identifierConfirm'));
@ -1080,17 +1073,19 @@ sub profileRecoverPasswordFinish {
identifier => $self->hashPassword($password),
passwordLastUpdated => time);
$self->_logSecurityMessage;
return $self->SUPER::login;
return $self->SUPER::www_login;
} else {
return $self->recoverPassword('<ul><li>'.$self->error.'</li></ul>');
return $self->www_recoverPassword('<ul><li>'.$self->error.'</li></ul>');
}
}
deprecate 'profileRecoverPasswordFinish' => 'www_profileRecoverPasswordFinish';
#-------------------------------------------------------------------
sub emailRecoverPasswordFinish {
sub www_emailRecoverPasswordFinish {
my $self = shift;
return $self->displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
return $self->www_displayLogin unless ($self->session->setting->get('webguiPasswordRecovery') ne '') and $self->isVisitor;
my $i18n = WebGUI::International->new($self->session);
my $session = $self->session;
@ -1108,12 +1103,12 @@ sub emailRecoverPasswordFinish {
# return error unless we get a valid user.\
unless ($user) {
return $self->recoverPassword( $i18n->get('recover password not found', 'AuthWebGUI') );
return $self->www_recoverPassword( $i18n->get('recover password not found', 'AuthWebGUI') );
}
# Make sure the user is Active
if ( $user->status ne "Active" ) {
return $self->recoverPassword( $i18n->get( 'password recovery disabled', 'AuthWebGUI' ) );
return $self->www_recoverPassword( $i18n->get( 'password recovery disabled', 'AuthWebGUI' ) );
}
# generate information necessry to proceed
@ -1122,7 +1117,7 @@ sub emailRecoverPasswordFinish {
$email = $user->profileField('email');
if ( ! $email ) {
return $self->recoverPassword( $i18n->get( 'no email address', 'AuthWebGUI' ) );
return $self->www_recoverPassword( $i18n->get( 'no email address', 'AuthWebGUI' ) );
}
my $authsettings = $self->get;
@ -1141,10 +1136,12 @@ sub emailRecoverPasswordFinish {
return "<h1>". $i18n->get('recover password banner', 'AuthWebGUI')." </h1> <br> <br> <h3>". $i18n->get('email recover password finish message', 'AuthWebGUI') . "</h3>";
}
deprecate emailRecoverPasswordFinish => 'www_emailRecoverPasswordFinish';
#-------------------------------------------------------------------
# handler for the link generated and mailed by emailRecoverPasswordFinish
sub emailResetPassword {
sub www_emailResetPassword {
my $self = shift;
my $errormsg = shift;
@ -1212,9 +1209,11 @@ sub emailResetPassword {
}
deprecate 'emailResetPassword' => 'www_emailResetPassword';
#-------------------------------------------------------------------
sub emailResetPasswordFinish {
sub www_emailResetPasswordFinish {
my $self = shift;
my $session = $self->session;
my ($form) = $session->quick(qw/form/);
@ -1238,15 +1237,17 @@ sub emailResetPasswordFinish {
# delete the emailRecoverPasswordVerificationNumber
$self->delete('emailRecoverPasswordVerificationNumber');
return $self->SUPER::login;
return $self->SUPER::www_login;
} else {
return $self->emailResetPassword($self->error);
return $self->www_emailResetPassword($self->error);
}
}
deprecate emailResetPasswordFinish => 'www_emailResetPasswordFinish';
#-------------------------------------------------------------------
sub resetExpiredPassword {
sub www_resetExpiredPassword {
my $self = shift;
my $uid = shift || $self->session->form->process("uid");
my $vars;
@ -1271,8 +1272,10 @@ sub resetExpiredPassword {
return WebGUI::Asset::Template->newById($self->session,$self->getExpiredPasswordTemplateId)->process($vars);
}
deprecate resetExpiredPassword => 'www_resetExpiredPassword';
#-------------------------------------------------------------------
sub resetExpiredPasswordSave {
sub www_resetExpiredPasswordSave {
my $self = shift;
my ($error,$u,$properties,$msg);
@ -1284,18 +1287,20 @@ sub resetExpiredPasswordSave {
$error .= '<li>'.$i18n->get(12,'AuthWebGUI').'</li>' if ($self->session->form->process("oldPassword") eq $self->session->form->process("identifier"));
$error .= $self->error if(!$self->_isValidPassword($self->session->form->process("identifier"),$self->session->form->process("identifierConfirm")));
return $self->resetExpiredPassword($u->userId, "<h1>".$i18n->get(70)."</h1><ul>".$error.'</ul>') if ($error);
return $self->www_resetExpiredPassword($u->userId, "<h1>".$i18n->get(70)."</h1><ul>".$error.'</ul>') if ($error);
$properties->{identifier} = $self->hashPassword($self->session->form->process("identifier"));
$properties->{passwordLastUpdated} =time();
$self->update($properties);
$self->_logSecurityMessage();
return $self->SUPER::login();
return $self->SUPER::www_login();
}
deprecate resetExpiredPasswordSave => 'www_resetExpiredPasswordSave';
#-------------------------------------------------------------------
sub validateEmail {
sub www_validateEmail {
my $self = shift;
my $session = $self->session;
my ($userId) = $session->db->quickArray("select userId from authentication where fieldData=? and fieldName='emailValidationKey' and authMethod='WebGUI'", [$session->form->process("key")]);
@ -1307,19 +1312,20 @@ sub validateEmail {
$self->session->db->write("DELETE FROM authentication WHERE userId = ? AND fieldName = 'emailValidationKey'", [$userId]);
$message = $i18n->get('email validation confirmed','AuthWebGUI');
}
return $self->displayLogin($message);
return $self->www_displayLogin($message);
}
deprecate validateEmail => 'www_validateEmail';
#-------------------------------------------------------------------
=head2 updateAccount ( )
=head2 www_updateAccount ( )
Sets properties to update and passes them to the superclass
=cut
sub updateAccount {
sub www_updateAccount {
my $self = shift;
my $i18n = WebGUI::International->new($self->session);
@ -1330,7 +1336,7 @@ sub updateAccount {
my $error = "";
if($self->isVisitor){
return $self->displayLogin;
return $self->www_displayLogin;
}
if($username){
@ -1373,8 +1379,10 @@ sub updateAccount {
$self->update($properties);
$self->session->user(undef,undef,$u);
return $self->displayAccount($display);
return $self->www_displayAccount($display);
}
deprecate updateAccount => 'www_updateAccount';
1;