From 3d6a8fa632b8d678ee1c89bd4848aa5b65cafe3a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Aug 2011 14:51:19 +0000 Subject: [PATCH] * Slight cleanup. --- src/lib/Hydra/Controller/Root.pm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 6fb2dfeb..1b4c001d 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -43,19 +43,16 @@ sub login :Local { my $username = $c->request->params->{username} || ""; my $password = $c->request->params->{password} || ""; - if($username eq "" && $password eq "" && ! defined $c->flash->{afterLogin}) { - my $baseurl = $c->uri_for('/'); - my $refurl = $c->request->referer; - $c->flash->{afterLogin} = $refurl if $refurl =~ m/^($baseurl)/ ; + if ($username eq "" && $password eq "" && ! defined $c->flash->{referer}) { + my $baseurl = $c->uri_for('/'); + my $refurl = $c->request->referer; + $c->flash->{referer} = $refurl if $refurl =~ m/^($baseurl)/; } if ($username && $password) { if ($c->authenticate({username => $username, password => $password})) { - $c->response->redirect( - defined $c->flash->{afterLogin} - ? $c->flash->{afterLogin} - : $c->uri_for('/')); - $c->flash->{afterLogin} = undef; + $c->response->redirect($c->flash->{referer} || $c->uri_for('/')); + $c->flash->{referer} = undef; return; } $c->stash->{errorMsg} = "Bad username or password."; @@ -68,7 +65,7 @@ sub login :Local { sub logout :Local { my ($self, $c) = @_; $c->logout; - $c->response->redirect($c->uri_for('/')); + $c->response->redirect($c->request->referer || $c->uri_for('/')); }