0

I'm new to phalcon and i used to learn invo example application. In security.php i found :

$auth = $this->session->get('auth');
        if (!$auth){
            $role = 'Guests';
        } else {
            $role = 'Users';
        }

are there any way to create user group with different assigned role like joomla? Thanks

icedwater
  • 4,701
  • 3
  • 35
  • 50

1 Answers1

0

What you can do is, when the user logs in set the session as follows :-

$this->session->set('auth', array(
    'username' => $user->username,
    'power' => $user->power //Assuming that you have power assigned to each user
));

Now when you need to check the user's role you can implement the following method :-

$auth = $this->session->get('auth');
if(!$auth) {
    $role = 'Guest';
} elseif($auth['power'] == 0) {
    $role = 'Admin';
} elseif($auth['power'] == 2) {
    $role = 'Sub-Admin';
} else {
    $role = 'User'; //If power equals to 1 or 2 then assign the role else assign normal user role
}

I hope this helps.

Jagjot
  • 5,816
  • 2
  • 24
  • 41