Using Auth (DB)

Please forgive me for what is surely a stupid question, but how do we begin using DB based auth? We are brand new to Yii and the very first table we need to create is the users table. I assume the authorization component has a recommend schema, but we can’t find anything anywhere about setting this up.

I’m sure there is a tutorial or document somewhere. Can someone lend us a hand?

I’m assuming that you’ve first read this:

http://www.yiiframework.com/doc/guide/1.1/en/topics.auth

You can find the schema for the auth tables in your framework folder under

framework/web/auth/schema-<db>.sql

Here’s an online version of the MySQL schema:

https://github.com/yiisoft/yii/blob/master/framework/web/auth/schema-mysql.sql

The user table schema is less well defined as the authorisation components are designed to work with your existing schema. The guide page linked above should get you started.

So basically, we design our own user table and then create our User model and then create a new UserIdentity class that uses that model.

Does that basically sum it up?

Yep, pretty much. It’ll be clearer once you try to implement it.

Try it out and ask about any specific issues as you encounter them.