Yii Login Form

I found the yii already has a login Form. LoginForm model and sites controller. What should be the structure of the table that yii use for login.

The default code generated by yiic uses a very simple authentication (admin/admin, user/user) and no table…

You can change that default code to use any table structure you have…

For more info check the definitive guide special topic: Authentication and Authorisation - http://www.yiiframework.com/doc/guide/1.1/en/topics.auth

how does this do login form where does it get the data for doing a login

After generating a webapp:

protected/controllers/SiteController - login action

protected/components/UserIdentity - login functionality (including list of users)

Try not to reinvent already invented wheel or open already opened doors. First of all, take a look at Blog Demo tutorial, where you should find simple implementation of using users table explained in details. Then I would even go deeper and reuse already invented solution for managing users (like Yii User extension) or their access rights (like Right extension by Chris).


i was struggling with the documentation on this website regarding yii authentication, and found the following site very useful for basic tutorials regarding yii, including custom authentication.

here are the links.


for custom authentication


I had to make some changes to LoginForm.php and UserIdentity.php and login.php separate from the changes in the above link to reflect changes made to yii since the article was written. For example now its $model NOT $form in login.php

I’ve included the files that I used to get custom authentication to work (only just got it working so no guarantees that its perfect).

As for your question regarding table structure I used


id int(10) unsigned NOT NULL AUTO_INCREMENT,

email varchar(80) NOT NULL,

pass char(40) NOT NULL,

role enum(‘reader’,‘editor’,‘writer’) NOT NULL,



I realise this is an old post, but hopefully it helps someone else.

PS Its my first post so had to make the url’s not look like url’s (helps prevent spam i spose)