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

@ -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';
} }

View file

@ -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
} }

View file

@ -28,6 +28,7 @@ You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
<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>