From e68f6098501457f950b169511b1e7d812784626f Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 7 Nov 2006 08:13:23 +0000 Subject: [PATCH] WebGUI::Session::Scratch->delete now acts more like Perl's delete()fix: redirectAfterLogin wouldn't work if displayLogin called from WebGUI::Operation::execute --- docs/changelog/7.x.x.txt | 3 +++ lib/WebGUI/Auth.pm | 17 +++++++++++++++-- lib/WebGUI/Session/Scratch.pm | 6 ++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 21c73a464..d8345a867 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -42,6 +42,9 @@ - fix: WebGUI::Operation::ProductManager added a tab with wrong name. - fix: WebGUI::Operation::Commerce www_selectPaymentGateway no longer forces user to choose gateway if they are only authorized to use one + - WebGUI::Session::Scratch->delete now returns the value deleted for + convenience, like Perl's built-in delete() function. + - fix: Auth redirectOnLogin wouldn't work if login called from Operation::execute() 7.1.3 - fix: SQLReport now returns error if can't find DatabaseLink diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 2a4f76be7..9007f8103 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -242,7 +242,6 @@ sub createAccountSave { } $self->session->user({user=>$u}); $self->_logLogin($userId,"success"); - $self->session->http->setStatus(201,"Account Registration Successful"); if ($self->session->setting->get("runOnRegistration")) { WebGUI::Workflow::Instance->create($self->session, { workflowId=>$self->session->setting->get("runOnRegistration"), @@ -252,6 +251,17 @@ sub createAccountSave { priority=>1 }); } + + + # If we have a redirectOnLogin, redirect the user + if ($self->session->scratch->get("redirectOnLogin")) { + my $url = $self->session->scratch->delete("redirectOnLogin"); + $self->session->http->setRedirect($url); + } else { + $self->session->http->setStatus(201,"Account Registration Successful"); + } + + return undef; } @@ -371,7 +381,10 @@ sub displayLogin { my $self = shift; my $method = $_[0] || "login"; my $vars = $_[1]; - unless ($self->session->form->process("op") eq "auth") { + # Automatically set redirectAfterLogin unless we've linked here directly + # or it's already been set. + unless ($self->session->form->process("op") eq "auth" + || $self->session->scratch->get("redirectAfterLogin") ) { $self->session->scratch->set("redirectAfterLogin",$self->session->url->page($self->session->env->get("QUERY_STRING"))); } my $i18n = WebGUI::International->new($self->session); diff --git a/lib/WebGUI/Session/Scratch.pm b/lib/WebGUI/Session/Scratch.pm index 4e93c7851..b43b7bee9 100644 --- a/lib/WebGUI/Session/Scratch.pm +++ b/lib/WebGUI/Session/Scratch.pm @@ -48,7 +48,8 @@ These methods are available from this package: =head2 delete ( name ) -Deletes a scratch variable. +Deletes a scratch variable. Returns the value of the deleted variable for +convenience, or undef if the variable was not defined. =head3 name @@ -60,8 +61,9 @@ sub delete { my $self = shift; my $name = shift; return undef unless ($name); - delete $self->{_data}{$name}; + my $value = delete $self->{_data}{$name}; $self->session->db->write("delete from userSessionScratch where name=? and sessionId=?", [$name, $self->session->getId]); + return $value; }