Different Authentification mode. Can you help me?

I’m developing a facebook application with Yii.

I want to use this type of authentification:

the person who use my application need to be authed with facebook authentification provided by facebook library.

When a person log to my app and is logged to facebook I know that it’s a valid user.

So the problem is that I don’t have a username and password to pass to UserIdentify.

But I need to use it couse I want this:

  • normal user are guest, they can access to all normal services.

  • Than we have PRO-user ( that have paid me a fee for special services ). And I want to login them like logged-users.

Maybe I don’t understand the yii auth and login.

Which is the role of UserIdentify? And UserIdentify.authenticate() only check if the user is in db and give him a "state"?

What does Yii::app->user->login() do?

Couse I want to "really login" only PRO-user and not normal user. But I want to save the User model that I own in the Yii::app->user->something so I can access to the user information ( normal and pro ) everywhere in my application.

What kind of information is used in the access control of a Controller?

Where is defined and how can I set if the user is a guest/admin/normal user/pro user?

Can someone exaplain me the whole situation? I read the documentation but I’m sorry I do not understand the Yii auth/user management.

If I store the "level" of the user in the Yii::app()->user->level and then I change the level in the User object to another, will Yii::app()->user->level be refreshed?

Which is the best usage of storing information in Yii::app()->user? Which informations have I to store there?

Thank you very much. Emanuele.

Hi Emanuele,

Have you concluded the best way to authenticate with Facebook?

if you do, could you share it, since I’m developing the facebook application as well.



You can create a FBUserIdentity class to auth user come to your app from FB. Extend Yii UserIdentity and override the authorize() method is all you need. That’s pretty simple !

As you wanna have 2 levels of user, use 2 UserIdentity classes, the other is similar to Yii’s sample (i bet you’ll understand it well if you read the doc again). For both UserIdentity class, when user is authed, setState(‘level’,…) and you can use Yii::app()->user->level later. Though, I prefer Yii::app()->user->getState(‘level’)

Hope this help

Hudson Nguyen ,

Could you please show me a piece of code here ..because i was doing same as you told here..but not get succeed.

now i have a problem that …facebook user is authenticate with on site.but he can not see a links on the home page which is only visible for registered user. but when i refresh my page then these link appear there. i am not getting whats wrong here…!!!

this is my extensions code for authentication:-

$identity=new UserFBIdentity($row[‘email’],$row[‘password’]);




somebody can help me…how could i fix it…!!


i was using your developed extension.but i need some more requirement that is why i modified it with my requirements.my code is working fine as i want it.but the only problem is that links which i used for authenticate user is not appearing on home page menu..!!

could you please help me out or tell me where i am doing wrong in authentication process.