Having issues setting up permissions

A place for users and developers of the Xataface to discuss and receive support.

Having issues setting up permissions

Postby shanehudg » Mon Dec 03, 2007 10:34 am

I've got my application up and running successfully and have customized the template and now I'm ready to start setting up relationships and actions and fill the database but before I get any more sensitive information on a public website, I wanted to go ahead and get the permissions set up. (I know I'm doing things a bit out of order but I want to get the application live as soon as possible and then while real time testing, customize it in greater detail.)

Anyway, back on topic. I followed the instructions to the letter in the getting started section on permissions. When I load the site, the login comes up as it should and when I enter the correct username and password for Admin (I have double checked the settings in the user table), I get the following fatal error:
Fatal error: The role '' is not a registered role. in /home/tddatali/public_html/projects/dataface/Dataface/PermissionsTool.php on line 341


I've searched backwards from this point through all the code and I can't find what might be generating the error. I believe it may be one of two things. Either the user variable is not initialized or the call for permissions.ini is not properly retrieving the Roles permissions since I've checked that the role is defined there. Can you offer any further insight into this? I think I'm missing part of the execution path since I can not find the call for permissions.ini but I am very new to PHP and am teaching myself as I go.

Thank you for your time.
Shane
shanehudg
 
Posts: 4
Joined: Fri Nov 30, 2007 2:59 pm

Postby shannah » Mon Dec 03, 2007 5:12 pm

Can you post your getPermissions() method?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shanehudg » Mon Dec 03, 2007 5:38 pm

[quote="shannah"]Can you post your getPermissions() method?


Here it is:
Code: Select all
function getPermissions(&$record){
         $auth =& Dataface_AuthenticationTool::getInstance();
         $user =& $auth->getLoggedInUser();
         if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
             // if the user is null then nobody is logged in... no access.
             // This will force a login prompt.
         $role = $user->val('Role');
         return Dataface_PermissionsTool::getRolePermissions($role);
             // Returns all of the permissions for the user's current role.
      }

It is directly copied from the getting started tutorial.
shanehudg
 
Posts: 4
Joined: Fri Nov 30, 2007 2:59 pm

Postby shannah » Mon Dec 03, 2007 6:24 pm

My best guess is that you have a user with a null role. The line:
Code: Select all
return Dataface_PermissionsTool::getRolePermissions($role);


tries to return the permissions for the current user's role, but if this role is empty, then it will be trying to get permissions for the '' role.

Workaround.

1. Handle the case where the user has no role.
2. Make sure that users always have a role assigned.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shanehudg » Tue Dec 04, 2007 4:46 pm

[quote="shannah"]My best guess is that you have a user with a null role. The line:
Code: Select all
return Dataface_PermissionsTool::getRolePermissions($role);


tries to return the permissions for the current user's role, but if this role is empty, then it will be trying to get permissions for the '' role.

Workaround.

1. Handle the case where the user has no role.
2. Make sure that users always have a role assigned.

-Steve



I've double checked the role assignments for the users (I only have two set up as a test right now: admin and guest) and both have roles assigned that are all uppercase and properly spelled. I can't find why it would be returning the current user's role as NULL. Any suggestions? I did notice that application delegate class and the permissionstool.php both have a function named getPermissions and they are different. Since these two files are closely related around the error event, could it be possible that the wrong function is being called by mistake?
shanehudg
 
Posts: 4
Joined: Fri Nov 30, 2007 2:59 pm

Postby shannah » Tue Dec 04, 2007 5:00 pm

Have you tried adding some debugging code to see which role is causing the problems.
e.g.
Code: Select all
...
$role = $user->val('Role');
echo "Role: $role";
return Dataface_PermissionsTool::getRolePermissions($role);


Another thing that could confuse is that column names are case sensitive. If your field name is 'role' then you should be doing $user->val('role') rather than $user->val('Role'), etc...

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shanehudg » Tue Dec 04, 2007 6:47 pm

Ok, I feel like an idiot now. I didn't think about the case sensitivity of the columns. That's exactly what the problem was. Thank you for your help. :)
shanehudg
 
Posts: 4
Joined: Fri Nov 30, 2007 2:59 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 29 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved