From 33ef55815e6e52394a6421ced0e91af2e7aea757 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Tue, 6 Jul 2010 07:27:55 +0000 Subject: [PATCH] Hydra/33: 'Sign in' should return to the referring page --- src/lib/Hydra/Controller/Root.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index b67b228e..c1609e47 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -37,12 +37,19 @@ sub login :Local { my $username = $c->request->params->{username} || ""; my $password = $c->request->params->{password} || ""; + if(! $username && ! defined $c->flash->{afterLogin}) { + my $baseurl = $c->uri_for('/'); + my $refurl = $c->request->referer; + $c->flash->{afterLogin} = $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; return; } $c->stash->{errorMsg} = "Bad username or password.";