Search code examples
yiiyii-extensions

The best user manager extension for yii?


What is the best user manager for yii in your opinion? On irc i heard yii-auth?

I need 2 types of users: 1) workers - they have limited access to diffrent panels. 2) clients - they have access to shops to buy products and some very limited other places.

Can i use module like yii-auth to 1) and 2)? Or it have sense only to 1)?

The application what i am writing is the shop with many with full complex funcionality like support etc.

What do you recommend?


Solution

  • If you want something simple, at authentication time, set in the SESSION the type of the user.

    // Example
    Yii::app()->user->setState('type', 'W'); // Worker
    Yii::app()->user->setState('type', 'C'); // Client
    

    And then, before performing some action that only one of the types of users can run, you do...

    if(Yii::app()->user->getState('type') === 'W') {
        // Action of the Worker
    } else {
        // Exception
    }
    

    If you need something more professional, you can control access to your site, through extension Yii Rights or Yii SRBAC and use the best for your case.