hey, this is only my second day playing with Yii so I don't know much. I am considering moving here from CakePHP.
I read the Creating First Yii Application tutorial and from there changed the login system to use my User model instead of the LoginForm model. Also I moved the login and logout actions to the user controller from the sites controller. This seemed like the right thing to do. Am I right? I then changed authenticate() in class UserIdentity to the following:
<?php public function authenticate() { $record=User::model()->findByAttributes(array('username'=>$this->username)); if ($record === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($record->password !== md5($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->username = $record->username; $this->errorCode = self::ERROR_NONE; } return !$this->errorCode; }
Now my problem is I can't figure out how to make the user info persistent. Right now it correctly persists the user name, but I need email and group fields also persisted. How can I do this?
Also, in my rules I have set these rules:
array(‘username, password, email, group_id’, ‘required’),
I chose these rules because on the registration page, all of those fields are required. But now that I am back to testing the login form, it is broken, because the email field is not required on that form, only on the registration form. What is the Yii way of handling this?
ps. does Yii have any convenience debug functions? for instance cake had pr($arg) which dumped $arg inside of <pre> tags. very handy. Also is there a way to get Yii to tell you a summary of the mysql quarries made?