Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more verbose bridge examples in growing guide
  • Loading branch information
kraih committed Feb 18, 2014
1 parent 7c943f8 commit 7673fb0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/Mojolicious/Guides/Growing.pod
Expand Up @@ -422,7 +422,9 @@ like this.
my $self = shift;

# Redirect to main page with a 302 response if user is not logged in
return $self->session('user') || !$self->redirect_to('index');
return 1 if $self->session('user');
$self->redirect_to('index');
return undef;
};

# A protected page auto rendering "protected.html.ep"
Expand Down Expand Up @@ -531,7 +533,9 @@ actual action code needs to be changed.

my $logged_in = $r->under(sub {
my $self = shift;
return $self->session('user') || !$self->redirect_to('index');
return 1 if $self->session('user');
$self->redirect_to('index');
return undef;
});
$logged_in->get('/protected');

Expand Down Expand Up @@ -592,7 +596,9 @@ Once again the actual action code does not change at all.

sub logged_in {
my $self = shift;
return $self->session('user') || !$self->redirect_to('index');
return 1 if $self->session('user');
$self->redirect_to('index');
return undef;
}

sub logout {
Expand Down

0 comments on commit 7673fb0

Please sign in to comment.