当我们使用symfony自带的sfGuardPlugin的时候。会自动生成登录验证页面。
默认情况下,页面中会有一个默认的参数叫_csrf_token的提交。
现在我们这边需要做个页面,但是不需要_csrf_token这个参数。
我们需要更改form,关闭CSRFProtection.
我们打开BasesfGuardFormSignin.class.php页面。
class BasesfGuardFormSignin extends BaseForm
{
public function setup()
{
//在页面中加入这一行,就能关闭CSRFProtection了。这样登录页面就没有_csrf_token了。
$this->disableCSRFProtection();
$this->setWidgets(array(
'username' => new sfWidgetFormInputText(),
'password' => newsfWidgetFormInputPasswor
d(array('type' =>'password')),
'remember' => new sfWidgetFormInputCheckbo
x(),
));
$this->setValidators(array(
'username' => new sfValidatorString(),
'password' => new sfValidatorString(),
'remember' => new sfValidatorBoolean(),
));
if(sfConfig::get('app_sf_guard_plugin_allow_login_with_email',true))
{
// 从配置文件中读取sf_guart_plugin_allow_login_with_email参数
$this->widgetSchema['username']->setLabel('用户名');
$this->widgetSchema['password']->setLabel('密码');
$this->widgetSchema['remember']->setLabel('记住我');
}
$this->validatorSchema->setPostValidator(newsfGuardValidatorUser());
$this->widgetSchema->setNameFormat('signin[%s]');
}
}
默认情况下,页面中会有一个默认的参数叫_csrf_token的提交。
现在我们这边需要做个页面,但是不需要_csrf_token这个参数。
我们需要更改form,关闭CSRFProtection.
我们打开BasesfGuardFormSignin.class.php页面。
class BasesfGuardFormSignin extends BaseForm
{
// 从配置文件中读取sf_guart_plugin_allow_login_with_email参数
}