Date: Wed, 16 Apr 2014 21:10:37 +0000 (UTC) From: Dag-Erling Smørgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r264557 - user/des/fbp/lib/FBP Message-ID: <201404162110.s3GLAb8f039282@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Wed Apr 16 21:10:36 2014 New Revision: 264557 URL: http://svnweb.freebsd.org/changeset/base/264557 Log: (and the rest of the controller) Added: user/des/fbp/lib/FBP/Controller.pm (contents, props changed) Added: user/des/fbp/lib/FBP/Controller.pm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/fbp/lib/FBP/Controller.pm Wed Apr 16 21:10:36 2014 (r264557) @@ -0,0 +1,52 @@ +use utf8; +package FBP::Controller; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller'; } + +=encoding utf8 + +=head1 NAME + +FBP::Controller - Superclass for FBP controllers + +=head1 DESCRIPTION + +This class provides common code for FBP controllers. + +=head1 METHODS + +=head2 require_user + +Verifies that the client is authenticated, and if not, redirects to +the login page. + +=cut + +sub require_user($$) { + my ($self, $c) = @_; + + if (!$c->user_exists) { + $c->response->redirect($c->uri_for_action('/login')); + $c->detach(); + } + return $c->user; +} + +=head1 AUTHOR + +Dag-Erling Smørgrav <des@freebsd.org> + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; + +# $FreeBSD$
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404162110.s3GLAb8f039282>