Correctly redirect to the referring page when logging in

This commit is contained in:
Eelco Dolstra
2013-02-21 14:38:18 +01:00
parent 26fa9ea0ea
commit 767cab6cd2
3 changed files with 18 additions and 16 deletions

View File

@ -43,7 +43,7 @@ sub login :Local {
my $username = $c->request->params->{username} || "";
my $password = $c->request->params->{password} || "";
if ($username eq "" && $password eq "" && ! defined $c->flash->{referer}) {
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)/;
@ -58,6 +58,8 @@ sub login :Local {
$c->stash->{errorMsg} = "Bad username or password.";
}
$c->keep_flash("referer");
$c->stash->{template} = 'login.tt';
}

View File

@ -97,7 +97,6 @@ sub notFound {
sub requireLogin {
my ($c) = @_;
$c->flash->{afterLogin} = $c->request->uri;
$c->response->redirect($c->uri_for('/login'));
$c->detach; # doesn't return
}