forward port of bugfix from 7.3.21

This commit is contained in:
Doug Bell 2007-07-14 00:04:20 +00:00
parent f07858a645
commit 15e3894b86
4 changed files with 77 additions and 40 deletions

View file

@ -72,6 +72,9 @@
- add: Password recovery can now be based on profile fields or simply by the - add: Password recovery can now be based on profile fields or simply by the
user's e-mail address. user's e-mail address.
7.3.21
- fix: Self-deactivation doesn't show login screen after success
7.3.20 7.3.20
- Added beta label to the beta components in the system, so people can more - Added beta label to the beta components in the system, so people can more
easily tell which parts of the system are a work in progress. easily tell which parts of the system are a work in progress.

View file

@ -337,26 +337,43 @@ sub deactivateAccount {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 deactivateAccountConfirm ( method ) =head2 deactivateAccountConfirm ( )
Superclass method that performs general functionality for deactivating accounts. Superclass method that performs general functionality for deactivating accounts.
=cut =cut
sub deactivateAccountConfirm { sub deactivateAccountConfirm {
my $self = shift; my $self = shift;
return $self->session->privilege->vitalComponent() if($self->userId eq '1' || $self->userId eq '3');
my $u = $self->user; # Cannot deactivate "Visitor" or "Admin" users this way
$u->status("Selfdestructed"); return $self->session->privilege->vitalComponent
$self->session->var->end(); if $self->userId eq '1' || $self->userId eq '3';
$self->session->user({userId=>'1'});
my $i18n = WebGUI::International->new($self->session);
# Change user's status
my $user = $self->user;
$user->status("Selfdestructed");
# TODO: Fix displayLogin in all subclasses to have the same prototype. THIS WILL BREAK API!
# Show the login form
#$self->logout;
#return $self->displayLogin(undef, {
#'login.message' => sprintf( $i18n->get("deactivateAccount success"), $user->username )
#});
$self->logout;
return undef;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 deleteParams ( ) =head2 deleteParams ( )
Removes the user's authentication parameters from the database for all authentication methods. This is primarily useful when deleting the user's account. Removes the user's authentication parameters from the database for all
authentication methods. This is primarily useful when deleting the user's
account.
=cut =cut
@ -436,35 +453,35 @@ Array ref of template vars from subclass
=cut =cut
sub displayLogin { sub displayLogin {
my $self = shift; my $self = shift;
my $method = $_[0] || "login"; my $method = $_[0] || "login";
my $vars = $_[1]; my $vars = $_[1];
# Automatically set redirectAfterLogin unless we've linked here directly # Automatically set redirectAfterLogin unless we've linked here directly
# or it's already been set to perform another operation # or it's already been set to perform another operation
unless ($self->session->form->process("op") eq "auth" unless ($self->session->form->process("op") eq "auth"
|| ($self->session->scratch->get("redirectAfterLogin") =~ /op=\w+/) ) { || ($self->session->scratch->get("redirectAfterLogin") =~ /op=\w+/) ) {
$self->session->scratch->set("redirectAfterLogin",$self->session->url->page($self->session->env->get("QUERY_STRING"))); $self->session->scratch->set("redirectAfterLogin",$self->session->url->page($self->session->env->get("QUERY_STRING")));
} }
my $i18n = WebGUI::International->new($self->session); my $i18n = WebGUI::International->new($self->session);
$vars->{title} = $i18n->get(66); $vars->{title} = $i18n->get(66);
my $action; my $action;
if ($self->session->setting->get("encryptLogin")) { if ($self->session->setting->get("encryptLogin")) {
$action = $self->session->url->page(undef,1); $action = $self->session->url->page(undef,1);
$action =~ s/http:/https:/; $action =~ s/http:/https:/;
} }
$vars->{'login.form.header'} = WebGUI::Form::formHeader($self->session,{action=>$action}); $vars->{'login.form.header'} = WebGUI::Form::formHeader($self->session,{action=>$action});
$vars->{'login.form.hidden'} = WebGUI::Form::hidden($self->session,{"name"=>"op","value"=>"auth"}); $vars->{'login.form.hidden'} = WebGUI::Form::hidden($self->session,{"name"=>"op","value"=>"auth"});
$vars->{'login.form.hidden'} .= WebGUI::Form::hidden($self->session,{"name"=>"method","value"=>$method}); $vars->{'login.form.hidden'} .= WebGUI::Form::hidden($self->session,{"name"=>"method","value"=>$method});
$vars->{'login.form.username'} = WebGUI::Form::text($self->session,{"name"=>"username"}); $vars->{'login.form.username'} = WebGUI::Form::text($self->session,{"name"=>"username"});
$vars->{'login.form.username.label'} = $i18n->get(50); $vars->{'login.form.username.label'} = $i18n->get(50);
$vars->{'login.form.password'} = WebGUI::Form::password($self->session,{"name"=>"identifier"}); $vars->{'login.form.password'} = WebGUI::Form::password($self->session,{"name"=>"identifier"});
$vars->{'login.form.password.label'} = $i18n->get(51); $vars->{'login.form.password.label'} = $i18n->get(51);
$vars->{'login.form.submit'} = WebGUI::Form::submit($self->session,{"value"=>$i18n->get(52)}); $vars->{'login.form.submit'} = WebGUI::Form::submit($self->session,{"value"=>$i18n->get(52)});
$vars->{'login.form.footer'} = WebGUI::Form::formFooter($self->session,); $vars->{'login.form.footer'} = WebGUI::Form::formFooter($self->session,);
$vars->{'anonymousRegistration.isAllowed'} = ($self->session->setting->get("anonymousRegistration")); $vars->{'anonymousRegistration.isAllowed'} = ($self->session->setting->get("anonymousRegistration"));
$vars->{'createAccount.url'} = $self->session->url->page('op=auth;method=createAccount'); $vars->{'createAccount.url'} = $self->session->url->page('op=auth;method=createAccount');
$vars->{'createAccount.label'} = $i18n->get(67); $vars->{'createAccount.label'} = $i18n->get(67);
return WebGUI::Asset::Template->new($self->session,$self->getLoginTemplateId)->process($vars); return WebGUI::Asset::Template->new($self->session,$self->getLoginTemplateId)->process($vars);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -263,9 +263,21 @@ sub deactivateAccount {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub deactivateAccountConfirm { sub deactivateAccountConfirm {
my $self = shift; my $self = shift;
return $self->displayLogin unless ($self->session->setting->get("selfDeactivation")); return $self->displayLogin unless ($self->session->setting->get("selfDeactivation"));
return $self->SUPER::deactivateAccountConfirm;
# 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 ));
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -297,7 +309,7 @@ sub displayAccount {
=head2 displayLogin ( ) =head2 displayLogin ( )
The initial login screen an unauthenticated user sees The initial login screen an unauthenticated user sees
=cut =cut

View file

@ -4262,6 +4262,11 @@ Get a copy of wget and use this: <code>wget -p -r --html-extension -k http://the
lastUpdated => 0, lastUpdated => 0,
}, },
'deactivateAccount success' => {
message => q{%s has been deactivated},
lastUpdated => 0,
},
}; };
1; 1;