Development

TracTickets (diff)

You must first sign up to be able to contribute.

Changes from Version 1 of TracTickets

Show
Ignore:
Author:
wowo (IP: 91.123.210.22)
Timestamp:
02/05/09 08:50:16 (9 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTickets

    v0 v1  
     1I'm using latest sfDoctrineGuardUser. When I'm trying to get users permissions, I'm getting only those, which are assigned to the user directly, but groups permissions, in which he is, are ommited.[[BR]] 
     2 
     3For example we have user john, he is in groups moderators and admins, group moderatrs has permission block_user, group admins has permission delete_user, and john has permission write_articles. [[BR]] 
     4 
     5$john->hasPermission('delete_user') and $john->hasPermission('block_user') returns false,[[BR]] 
     6$john->hasPermission('write_articles') returns true,[[BR]] 
     7array_keys($john->getAllPermissions()) returns array('write_articles','block_user','delete_user')[[BR]] 
     8 
     9The solution for me is to override sfGuardSecuirtyUser::hasPermissions in this way: 
     10 
     11{{{ 
     12  public function hasPermission($name) 
     13  { 
     14    if ( !($guardUser = $this->getGuardUser()) ) { 
     15      return false; 
     16    } 
     17    $guardUser->loadGroupsAndPermissions(); 
     18    return isset($guardUser->allPermissions[$name]); //use allPermissions instead of permissions array 
     19  } 
     20}}}