forked from lix-project/hydra
Correctly redirect to the referring page when logging in
This commit is contained in:
parent
26fa9ea0ea
commit
767cab6cd2
3 changed files with 18 additions and 16 deletions
|
@ -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,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') %]">
|
||||
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<label class="control-label">User name</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span3" name="username" value=""></input>
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<label class="control-label">User name</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span3" name="username" value=""></input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="span3" name="password" value=""></input>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="span3" name="password" value=""></input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" name="login" value="Sign in" class="btn btn-primary" />
|
||||
</div>
|
||||
<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