forked from lix-project/hydra
Hydra/33: 'Sign in' should return to the referring page
This commit is contained in:
parent
b8b976fb9f
commit
33ef55815e
1 changed files with 7 additions and 0 deletions
|
@ -37,12 +37,19 @@ sub login :Local {
|
||||||
my $username = $c->request->params->{username} || "";
|
my $username = $c->request->params->{username} || "";
|
||||||
my $password = $c->request->params->{password} || "";
|
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 ($username && $password) {
|
||||||
if ($c->authenticate({username => $username, password => $password})) {
|
if ($c->authenticate({username => $username, password => $password})) {
|
||||||
$c->response->redirect(
|
$c->response->redirect(
|
||||||
defined $c->flash->{afterLogin}
|
defined $c->flash->{afterLogin}
|
||||||
? $c->flash->{afterLogin}
|
? $c->flash->{afterLogin}
|
||||||
: $c->uri_for('/'));
|
: $c->uri_for('/'));
|
||||||
|
$c->flash->{afterLogin} = undef;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$c->stash->{errorMsg} = "Bad username or password.";
|
$c->stash->{errorMsg} = "Bad username or password.";
|
||||||
|
|
Loading…
Reference in a new issue