Permalink
Browse files

use new extended current_user_can and error helper to

  issue better errors
  • Loading branch information...
1 parent e902df1 commit 890ec91db454afd1568c811e38ecf26ea5ce312a @ruz ruz committed May 12, 2009
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/Wifty/Dispatcher.pm
View
19 lib/Wifty/Dispatcher.pm
@@ -41,15 +41,16 @@ on '/', run {
# Create a page
on '/create/*', run {
- set page => $1;
- set action => Jifty->web->new_action( class => 'CreatePage' );
-
- my $p = Wifty::Model::Page->new();
- if($p->current_user_can('create')) {
- show("/create");
- } else {
- show("/no_such_page");
- }
+ set page => $1;
+ set action => Jifty->web->new_action( class => 'CreatePage' );
+
+ my $p = Wifty::Model::Page->new;
+ my ($can, $reason) = $p->current_user_can('create');
+ unless ( $can ) {
+ error( create => $reason);
+ } else {
+ show("/create");
+ }
};
# View or edit a page

0 comments on commit 890ec91

Please sign in to comment.