Added CAPTCHA to application generated by yiic webapp

This commit is contained in:
qiang.xue
2008-10-07 03:02:58 +00:00
parent 8e4a47c132
commit 1f2bb263c1
3 changed files with 42 additions and 0 deletions

View File

@@ -2,6 +2,20 @@
class UserController extends CController
{
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
// captcha action renders the CAPTCHA image
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xEBF4FB,
),
);
}
/**
* Displays a login form to login a user.
*/
@@ -41,6 +55,7 @@ class LoginForm extends CFormModel
public $username;
public $password;
public $rememberMe;
public $verifyCode;
/**
* Declares the validation rules.
@@ -51,10 +66,23 @@ class LoginForm extends CFormModel
{
return array(
array('username, password', 'required'),
array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),
array('password', 'authenticate'),
);
}
/**
* Declares attribute labels.
* If not declared here, an attribute would have a label
* the same as the attribute name with the first letter in upper case.
*/
public function attributeLabels()
{
return array(
'verifyCode'=>'Verification Code',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().