Permalink
Browse files

Adding code to check that a user is logged in and has permission. Thi…

…s is very draft and needs some love and attention
  • Loading branch information...
1 parent 834c165 commit f44aafc34fc02339137f4218a254513ce8d2cce3 @idnorton idnorton committed Dec 7, 2011
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/PresentingPerl/Web/Controller/Admin.pm
@@ -3,11 +3,24 @@ package PresentingPerl::Web::Controller::Admin;
use Moose;
use namespace::autoclean;
-BEGIN { extends 'Catalyst::Controller' }
+BEGIN { extends 'Catalyst::Controller::ActionRole' }
sub root :Path :Args(0) {
my ($self, $c) = @_;
+ my $user;
+
+ if($user = $c->user) {
+ unless($user->get_object->has_role('admin')) {
+ $c->redirect('/login');
+ }
+ }
+
+ else {
+ $c->redirect('/login');
+
+ }
+
my $buckets = $c->model('DB::Bucket');
$c->stash->{current_view} = 'Zoom';

0 comments on commit f44aafc

Please sign in to comment.