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 $username = $c->request->params->{username} || "";
|
||||||
my $password = $c->request->params->{password} || "";
|
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 $baseurl = $c->uri_for('/');
|
||||||
my $refurl = $c->request->referer;
|
my $refurl = $c->request->referer;
|
||||||
$c->flash->{referer} = $refurl if $refurl =~ m/^($baseurl)/;
|
$c->flash->{referer} = $refurl if $refurl =~ m/^($baseurl)/;
|
||||||
|
@ -58,6 +58,8 @@ sub login :Local {
|
||||||
$c->stash->{errorMsg} = "Bad username or password.";
|
$c->stash->{errorMsg} = "Bad username or password.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$c->keep_flash("referer");
|
||||||
|
|
||||||
$c->stash->{template} = 'login.tt';
|
$c->stash->{template} = 'login.tt';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,6 @@ sub notFound {
|
||||||
|
|
||||||
sub requireLogin {
|
sub requireLogin {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
$c->flash->{afterLogin} = $c->request->uri;
|
|
||||||
$c->response->redirect($c->uri_for('/login'));
|
$c->response->redirect($c->uri_for('/login'));
|
||||||
$c->detach; # doesn't return
|
$c->detach; # doesn't return
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,25 @@ You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
|
||||||
|
|
||||||
<form class="form-horizontal" method="post" action="[% c.uri_for('/login') %]">
|
<form class="form-horizontal" method="post" action="[% c.uri_for('/login') %]">
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">User name</label>
|
<label class="control-label">User name</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="span3" name="username" value=""></input>
|
<input type="text" class="span3" name="username" value=""></input>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Password</label>
|
<label class="control-label">Password</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="password" class="span3" name="password" value=""></input>
|
<input type="password" class="span3" name="password" value=""></input>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" name="login" value="Sign in" class="btn btn-primary" />
|
<input type="submit" name="login" value="Sign in" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue