[Jifty-commit] r4065 - in apps/CASPlus/trunk: lib/CASPlus

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Sep 10 12:43:00 EDT 2007


Author: sterling
Date: Mon Sep 10 12:42:59 2007
New Revision: 4065

Modified:
   apps/CASPlus/trunk/   (props changed)
   apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm

Log:
 r11175 at riddle:  andrew | 2007-09-04 12:04:41 -0500
 Fixing duplicate dispatcher rules.


Modified: apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm
==============================================================================
--- apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm	(original)
+++ apps/CASPlus/trunk/lib/CASPlus/Dispatcher.pm	Mon Sep 10 12:42:59 2007
@@ -23,118 +23,124 @@
 
 =head2 before **
 
-This rule grants superuser access to the requester when there are no users.
+Grants superuser access to the requester when there are no users.
+
+Configures the menu items for the Administration page.
 
 =cut
 
 before '**' => run {
-    my $users = CASPlus::Model::UserCollection->new;
-    $users->unlimit;
-    if ($users->count) {
-        Jifty->api->deny('CreateFirstUser');
-    }
-    else {
-        Jifty->web->current_user->is_superuser(1);
-    }
-};
 
-on '/' => run {
-    my $users = CASPlus::Model::UserCollection->new;
-    $users->unlimit;
-    unless ($users->count) {
-        redirect '/admin/setup';
+    # Grant special access to any visitor if there is no superuser
+    {
+        my $users = CASPlus::Model::UserCollection->new;
+        $users->unlimit;
+        if ($users->count) {
+            # This is only available prior to the first user being created, duh
+            Jifty->api->deny('CreateFirstUser');
+        }
+        else {
+            Jifty->web->current_user->is_superuser(1);
+        }
     }
-}
-
-=head2 before **
-
-This rule configures the menu items for the Administration page.
 
-=cut
-
-before '**' => run {
-    my $menu = CASPlus->admin_menu;
-    my $current_user = Jifty->web->current_user;
+    # Setup the administration menus
+    {
+        my $menu = CASPlus->admin_menu;
+        my $current_user = Jifty->web->current_user;
+
+        # Stop now if they ain't an admin
+        return unless $current_user->may_administrate;
+
+        # Top-level items
+        my $profiles = 
+            $menu->child( Profiles => label => 'Profiles', side => 'left' );
+        my $users    =
+            $menu->child( Users    => label => 'Users',    side => 'left' );
+        my $sessions =
+            $menu->child( Sessions => label => 'Sessions', side => 'right' );
+
+        # Profile menu items
+        if ($current_user->may_manage_profiles) {
+            $profiles->child( Profile => 
+                label       => _('Profile Definitions'), 
+                url         => '/admin/profile/definitions',
+                description => _('Configure the profile definitions for storing additional user, group, and other information in your authentication database.'),
+            );
+            $profiles->child( ProfileProperty =>
+                label       => _('Profile Properties'),
+                url         => '/admin/profile/properties',
+                description => _('Add properties to your profile definitions for holding additional information like name, email address, street address, phone numbers, etc.'),
+            );
+            $profiles->child( ProfileRelationship =>
+                label       => _('Profile Relationships'),
+                url         => '/admin/profile/relationships',
+                description => _('Link profiles together in relationships to provide memberships, partnerships, and other profile connections.'),
+            );
+        }
 
-    # Stop now if they ain't an admin
-    return unless $current_user->may_administrate;
+        # User menu
+        if ($current_user->may_manage_users) {
+            $users->child( User =>
+                label       => _('Users'),
+                url         => '/admin/user/users',
+                description => _('Manage the user accounts that may authenticate against the CAS server.'),
+            );
+        }
+        if ($current_user->may_manage_roles) {
+            $users->child( Role =>
+                label       => _('Roles'),
+                url         => '/admin/user/roles',
+                description => _('Manage the roles that may be granted to user accounts to grant special privileges within the CAS server and in client services.'),
+            );
+        }
 
-    # Top-level items
-    my $profiles = 
-        $menu->child( Profiles => label => 'Profiles', side => 'left' );
-    my $users    =
-        $menu->child( Users    => label => 'Users',    side => 'left' );
-    my $sessions =
-        $menu->child( Sessions => label => 'Sessions', side => 'right' );
-
-    # Profile menu items
-    if ($current_user->may_manage_profiles) {
-        $profiles->child( Profile => 
-            label       => _('Profile Definitions'), 
-            url         => '/admin/profile/definitions',
-            description => _('Configure the profile definitions for storing additional user, group, and other information in your authentication database.'),
+        # Sessions menu
+        $sessions->child( AccessLog =>
+            label       => _('Access Log'),
+            url         => '/admin/session/access',
+            description => _('See a log of authentication activity that has been performed on the CAS server.'),
         );
-        $profiles->child( ProfileProperty =>
-            label       => _('Profile Properties'),
-            url         => '/admin/profile/properties',
-            description => _('Add properties to your profile definitions for holding additional information like name, email address, street address, phone numbers, etc.'),
+        $sessions->child( ErrorLog =>
+            label       => _('Error Log'),
+            url         => '/admin/session/errors',
+            description => _('Check the error log to see if there have been any problems with the CAS application.'),
         );
-        $profiles->child( ProfileRelationship =>
-            label       => _('Profile Relationships'),
-            url         => '/admin/profile/relationships',
-            description => _('Link profiles together in relationships to provide memberships, partnerships, and other profile connections.'),
+        $sessions->child( Status =>
+            label       => _('Status'),
+            url         => '/admin/session/status',
+            description => _('The status screen is a dashboard showing basic usage statistics and reports about the CAS server.'),
         );
-    }
 
-    # User menu
-    if ($current_user->may_manage_users) {
-        $users->child( User =>
-            label       => _('Users'),
-            url         => '/admin/user/users',
-            description => _('Manage the user accounts that may authenticate against the CAS server.'),
+        # Add the Administer item to main navigation
+        my $nav = Jifty->web->navigation;
+        $nav->child( Administer =>
+            label      => _('Administer'),
+            url        => '/admin',
+            sort_order => 50,
         );
     }
-    if ($current_user->may_manage_roles) {
-        $users->child( Role =>
-            label       => _('Roles'),
-            url         => '/admin/user/roles',
-            description => _('Manage the roles that may be granted to user accounts to grant special privileges within the CAS server and in client services.'),
-        );
-    }
-
-    # Sessions menu
-    $sessions->child( AccessLog =>
-        label       => _('Access Log'),
-        url         => '/admin/session/access',
-        description => _('See a log of authentication activity that has been performed on the CAS server.'),
-    );
-    $sessions->child( ErrorLog =>
-        label       => _('Error Log'),
-        url         => '/admin/session/errors',
-        description => _('Check the error log to see if there have been any problems with the CAS application.'),
-    );
-    $sessions->child( Status =>
-        label       => _('Status'),
-        url         => '/admin/session/status',
-        description => _('The status screen is a dashboard showing basic usage statistics and reports about the CAS server.'),
-    );
-
-    # Add the Administer item to main navigation
-    my $nav = Jifty->web->navigation;
-    $nav->child( Administer =>
-        label      => _('Administer'),
-        url        => '/admin',
-        sort_order => 50,
-    );
 };
 
 =head2 ROOT
 
-Automatically redirects to L</login>.
+Redirects the user to /admin/setup if no superuser account has been created yet.
+
+Otherwise, automatically redirects to L</login>.
 
 =cut
 
-on '' => redirect '/login';
+on '' => run {
+    my $users = CASPlus::Model::UserCollection->new;
+    $users->unlimit;
+    unless ($users->count) {
+        redirect '/admin/setup';
+    }
+
+    else {
+        redirect '/login';
+    }
+}
 
 =head2 GET login
 


More information about the Jifty-commit mailing list