Correctly redirect to the referring page when logging in
This commit is contained in:
parent
26fa9ea0ea
commit
767cab6cd2
|
@ -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';
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
|
|||
|
||||
<form class="form-horizontal" method="post" action="[% c.uri_for('/login') %]">
|
||||
|
||||
<fieldset>
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<label class="control-label">User name</label>
|
||||
<div class="controls">
|
||||
|
@ -28,6 +28,7 @@ You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
|
|||
<div class="form-actions">
|
||||
<input type="submit" name="login" value="Sign in" class="btn btn-primary" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in a new issue