Page 1 of 1

Authentication not working

PostPosted: Tue Feb 21, 2012 5:05 pm
by Dataguru
I added the _auth specs to my config.ini
Code: Select all
[_auth]
users_table = mytablename
username_column = myunfieldname
password_column = mypwfieldname


in the staff table created an ENUM field populated with the built in roles from the xataface/permissions.ini file
added my username and login info and made my role MANAGER.

copied and pasted the code into from the tutorial tar.gz file as per the tutorial
/conf/ApplicationDelegate.php
Code: Select all
<?
/**
* A delegate class for the entire application to handle custom handling of
* some functions such as permissions and preferences.
*/
class conf_ApplicationDelegate {
    /**
     * Returns permissions array.  This method is called every time an action is
     * performed to make sure that the user has permission to perform the action.
     * @param record A Dataface_Record object (may be null) against which we check
     *               permissions.
     * @see Dataface_PermissionsTool
     * @see Dataface_AuthenticationTool
     */
     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.
      }
}
?>


when I hit the site, it displays part of the code in the ApplicationDelegate php file and nothing else:
Code: Select all
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. } } ?>


is it a php issue with -> ?
our PHP version is 5.3.3 running on Apache/2.2.3 (Red Hat)

Thanks,
Betty

Re: Authentication not working

PostPosted: Tue Feb 21, 2012 11:36 pm
by samhans
hai friend;

the problem is with your application delegate class

can you give me the fieldname in users table you have specified

--samhans

Re: Authentication not working

PostPosted: Tue Feb 21, 2012 11:38 pm
by samhans
hai friend ;
what i noticed that you have named the conf.ini file as config.ini . If it is true then change it to conf.ini

hope it help you

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 3:13 am
by ADobkin
It may be an issue with the short open tag in your ApplicationDelegate.php file. Try replacing the first line with:

Code: Select all
<?php

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 7:58 am
by Dataguru
sam: a typo here on my part. it is conf.ini on my site.

Steve... that worked!

permissions appear to be working. I've tested Read only and manager so far.

When I login with manager permissions I see 3 options on the control panel.
Migrations
Output cache
Build Search Index

output cache returns a blank page.

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 8:24 am
by Dataguru
wow. logged in manager role. returned to the index from the control panel and now i'm getting just a white screen with no html at all in it. That can't be good. lol

cleared the files in /templates_c/dataface
removed /conf/ApplicationDelegate.php

still getting a white screen.

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 8:45 am
by Dataguru
from the browser I also ran
/xataface/actions/clear_cache.php
/xataface/actions/clear_views.php

still getting a white screen.

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 9:09 am
by samhans
exactly what you want to say. you can't able.to get the table view or something else

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 10:10 am
by shannah
If you're getting a white screen, then there is an error. It will be reported in your error log. Check the error log.

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 12:03 pm
by Dataguru
I checked the log and didn't see an error. Went and did something else for a while and just refreshed again and it's happy now.
Could it be related to sessions?

I'm going to try adding the permissions code again.

Re: Authentication not working

PostPosted: Wed Feb 22, 2012 12:23 pm
by shannah
If you get a blank page and there's no error listing, then you need to check that the errors are be logged where you think they are.
http://xataface.com/wiki/Troubleshooting

Re: Authentication not working

PostPosted: Thu Feb 23, 2012 9:14 am
by Dataguru
I just checked the php.ini file and indeed <? is turned off.
could that setting be messing with any of the xataface code elsewhere?

I also turned on displaying errors per your link and embedded the code in index.php to display them.
The reason I ask is that I was attempting to use delegate classes to create a custom title for records and even if I replace the initial <? with <?php, it's still not working. I turned on display errors and none are being thrown. (verified that by checking the error log).

<?php
class tables_ProgObj {

function getTitle(&$record){
return $record->val('ObjectiveNo');
}

function titleColumn(){
return "CONCAT('Objective #', ObjectiveNo)";
}
}

?>

Re: Authentication not working

PostPosted: Thu Feb 23, 2012 10:51 am
by shannah
That's a red herring. Xataface should work fine with standard php open tags. Do you get this white screen on every page load or only when you save something.

Before digging into the actual problem you should verify that errors do get reported. Make a simple PHP script that contains obvious errors and try to run it. Then check the error log to see if they show up. Make changes until you can get errors to show up in your error log, then you can try to debug the problem at hand.

-Steve

Re: Authentication not working

PostPosted: Thu Feb 23, 2012 12:16 pm
by Dataguru
That white screen issue yesterday magically resolved itself. I spent a couple of hours doing something else, came back and everything was working fine.

I believe I have it set up correctly now to display errors on the screen.
Added php_flag display_errors on to .htaccess
And added
error_reporting(E_ALL);
ini_set('display_errors', 'on');
to my index.php file

I just intentionally generated a php error and it did show up on the screen, however, it's not in the httpd log. I'm checking with my sysadmin to see where php errors are being logged.

Re: Authentication not working

PostPosted: Thu Feb 23, 2012 2:59 pm
by Dataguru
I think I had two things going on.
1) the file should have been named after the table
2) the default permissions weren't set to execute.