1Catalyst::ActionRole::NUeseedrsLCoognitnr(i3b)uted PerlCDaotcaulmyesntt:a:tAicotnionRole::NeedsLogin(3)
2
3
4
6 Catalyst::ActionRole::NeedsLogin - checks if a user is logged in and if
7 not redirects him to login page
8
10 package MyApp::Controller::NeedsAuth;
11
12 use Moose;
13 use namespace::autoclean;
14
15 # One needs to inherit from Catalyst::Controller in order
16 # to get the Does('NeedsLogin') functionality.
17 BEGIN { extends 'Catalyst::Controller'; }
18
19 sub inbox : Path Does('NeedsLogin') {
20 # Redirects to /login if not logged in
21 my ($self, $c) = @_;
22
23 $c->stash->{template} = "inbox.tt2";
24
25 return;
26 }
27
28 sub inbox : Path Does('NeedsLogin') :LoginRedirectMessage('Your custom Message') {
29 # Redirects to /login if not logged in-
30 }
31
32 # Turn on in config
33 MyApp->config('Contoller::Login' => { traits => ['WithRedirect'] });
34
36 Provides a ActionRole for forcing the user to login.
37
39 execute
40 If there is no logged-in user, call the login_redirect() method in the
41 'Login' controller with the Catalyst context object, $c, and the
42 message specified by the ":LoginRedirectMessage('Message here')" method
43 attribute (see the synopsis).
44
45 If there is a user logged-in (i.e: "$c->user" is true), execute the
46 body of the action as it is.
47
49 CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect
50 CatalystX::SimpleLogin::Controller::Login
51 CatalystX::SimpleLogin::Form::Login
52
54 See CatalystX::SimpleLogin for authors.
55
57 See CatalystX::SimpleLogin for license.
58
59
60
61perl v5.32.1 2021-01-26Catalyst::ActionRole::NeedsLogin(3)