record permissions

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

record permissions

Postby yokai » Fri Sep 05, 2008 5:13 am

Hi Steve,

What can I do to restrict access to all records in a table except that which belongs to the logged in user with xataface.

Regards
worship the Creator of the Universe and not the creation
yokai
 
Posts: 5
Joined: Wed May 07, 2008 7:28 am
Location: Ghana

Postby shannah » Fri Sep 05, 2008 1:27 pm

Suppose you have a column in each record that records the username of the owner, called 'owner'.

Then in your delegate class:

Code: Select all
function getPermissions(&$record){
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUser();
    if ( $record and $user and $record->val('owner') == $user->val('username') ){
        return Dataface_PermissionsTool::ALL();
    }
    return Dataface_PermissionsTool::NO_ACCESS();
}



Unfortunately in list view it will still show all records, it will just say "NO ACCESS" to the records that you don't have access to.

You can correct this by adding a security filter.

In your delegate class:

Code: Select all
function init(&$table){
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUser();
    if ( $user ){
        $table->setSecurityFilter(array('owner'=>'='.$user->val('username')));
    }
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: record permissions

Postby Philipp Wenzel » Tue Jun 19, 2012 9:12 am

Hi,
is this solution still working?

I try to allow my users to access only their data. But with this code i get this error:
Fatal error: Cannot redeclare init() (previously declared in /home/www/cwcity/hosting/i/r/irgps/htdocs/xataface-1.3.2/init.php:22) in /home/www/cwcity/hosting/i/r/irgps/htdocs/conf/ApplicationDelegate.php on line 20

Greetz
Philipp Wenzel
 
Posts: 15
Joined: Sat May 05, 2012 7:10 am

Re: record permissions

Postby shannah » Wed Jun 20, 2012 10:16 am

You need to implement init() inside of your delegate class so that it is a method of the delegate class and not a global function.

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


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 12 guests

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