Skip to content

Commit

Permalink
Removed fine grained roles in favour of groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Haggai Alavi committed Oct 27, 2009
1 parent 7b28aff commit 1cfe3e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Binary file modified ez_360.db
Binary file not shown.
12 changes: 5 additions & 7 deletions lib/EZ/360/Controller/Article.pm
Expand Up @@ -19,7 +19,7 @@ Catalyst Controller.
sub create : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [ qw/can-create-article/ ] );
$c->forward( '/check_user_roles', [qw/user/] );

if ( lc $c->request->method() eq 'post' ) {
my $title = $c->request->body_params->{'title'};
Expand Down Expand Up @@ -64,8 +64,7 @@ sub create : Local : Args(0) {
sub list : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles',
[ qw/ can-create-article can-update-article can-delete-article / ] );
$c->forward( '/check_user_roles', [qw/user/] );

$c->stash(
articles => [ $c->model('DB::Article')->all() ],
Expand All @@ -89,7 +88,7 @@ sub id : Chained('/') : PathPart('article') : CaptureArgs(1) {
sub delete : Chained('id') : PathPart('delete') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [ qw/can-delete-article/ ] );
$c->forward( '/check_user_roles', [qw/user/] );

if ( lc $c->request->method() eq 'post' ) {
eval { $c->stash->{article}->delete(); };
Expand Down Expand Up @@ -122,7 +121,7 @@ sub delete : Chained('id') : PathPart('delete') : Args(0) {
sub update : Chained('id') : PathPart('update') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [ qw/can-update-article/ ] );
$c->forward( '/check_user_roles', [qw/user/] );

if ( lc $c->request->method() eq 'post' ) {
my $title = $c->request->body_params->{'title'};
Expand Down Expand Up @@ -162,8 +161,7 @@ sub update : Chained('id') : PathPart('update') : Args(0) {
sub retrieve : Chained('id') : PathPart('retrieve') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles',
[ qw/ can-create-article can-update-article can-delete-article / ] );
$c->forward( '/check_user_roles', [qw/user/] );

$c->stash( template => 'article/retrieve.html' );
}
Expand Down
6 changes: 6 additions & 0 deletions lib/EZ/360/Controller/Page.pm
Expand Up @@ -23,6 +23,8 @@ Catalyst Controller.
sub create : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [qw/user/] );

if ( lc $c->request->method() eq 'post' ) {
my $title = $c->request->body_params->{'title'};
my $articles_string = $c->request->body_params->{'articles-string'};
Expand Down Expand Up @@ -72,6 +74,8 @@ sub create : Local : Args(0) {
sub list : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [qw/user/] );

$c->stash(
pages => [ $c->model('DB::Page')->all() ],
template => 'page/list.html'
Expand All @@ -94,6 +98,8 @@ sub id : Chained('/') : PathPart('page') : CaptureArgs(1) {
sub retrieve : Chained('id') : PathPart('retrieve') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [qw/user/] );

$c->stash( template => 'page/retrieve.html' );
}

Expand Down
12 changes: 5 additions & 7 deletions lib/EZ/360/Controller/User.pm
Expand Up @@ -19,7 +19,7 @@ Catalyst Controller.
sub create : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [qw/can-create-user/] );
$c->forward('/check_user_roles');

if ( lc $c->request->method() eq 'post' ) {
my $username = $c->request->body_params->{'username'};
Expand Down Expand Up @@ -74,8 +74,7 @@ sub create : Local : Args(0) {
sub list : Local : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles',
[qw/ can-create-user can-delete-user can-update-user /] );
$c->forward( '/check_user_roles', [qw/user/] );

$c->stash(
users_rs => $c->model('DB::User'),
Expand All @@ -100,7 +99,7 @@ sub update : Chained('id') : PathPart('update') : Args(0) {
my $user = $c->stash->{user};

if ( $c->user->id() != $user->id() ) {
$c->forward( '/check_user_roles', [qw/can-update-user/] );
$c->forward('/check_user_roles');
}

if ( lc $c->request->method() eq 'post' ) {
Expand Down Expand Up @@ -162,7 +161,7 @@ sub update : Chained('id') : PathPart('update') : Args(0) {
sub delete : Chained('id') : PathPart('delete') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles', [qw/can-delete-user/] );
$c->forward('/check_user_roles');

if ( lc $c->request->method() eq 'post' ) {
eval { $c->stash->{user}->delete(); };
Expand Down Expand Up @@ -193,8 +192,7 @@ sub delete : Chained('id') : PathPart('delete') : Args(0) {
sub retrieve : Chained('id') : PathPart('retrieve') : Args(0) {
my ( $self, $c ) = @_;

$c->forward( '/check_user_roles',
[qw/ can-create-user can-delete-user can-update-user /] );
$c->forward( '/check_user_roles', [qw/user/] );

$c->stash( template => 'user/retrieve.html' );
}
Expand Down

0 comments on commit 1cfe3e1

Please sign in to comment.