在AppController的确定包括这样的功能:
public function beforeFilter() {
Security::setHash('sha1');
}
你是说你的注册是sha1
现在在你的数据库中你的字段'password'应该是VARCHAR(30)不能超过30个字符。
而且我不舒尔这个线register.ctp,并有一个逗号更后真这是一个错误
<?php echo $this->Form->create('User',array('type' => 'file','novalidate' => true,));?>
为什么是一个文件?我的事情,只是应该是这个
<?php echo $this->Form->create('User');?>
和NOVALIDATE可以与真正的数据库进行初始化,则只能升级到新的价值
确定。 我告诉过你现在必须在AppController中添加什么,现在将其添加到UserController中。这就是当你查看表单以多次存储用户信息以使用sha1加密密钥时所发生的情况,这是我们在注册时存储在数据库中的加密。但是,登录时可能会发送另一种类型的加密,并且验证数据进行验证比较a(sha1(密码注册)==其他加密(登录密码))时,通常情况并不相同,这是因为特定的beforeFilter在加密密钥中。
加入这一点,并改变用户控制器:
public function beforeFilter() {
parent::beforeFilter();
}
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
if($this->Auth->user('activated')==1){
$this->Session->setFlash(__('Bienvenido, '. $this->Auth->user('username')));
return $this->redirect($this->Auth->redirectUrl());
}else{
$this->Session->setFlash(__('Your Email is not verified. Please verify and try again.'));
$this->redirect($this->Auth->logout());
}
} else {
$this->Session->setFlash(__('Invalid Username or Password please try again'));
}
}
}
他是对的!在模型中使用$ this->数据,在控制器中使用$ this-> request-> data! 功能登录(){ \t如果($这个 - >请求 - >是( '后')){ \t \t如果($这个 - > Auth->登录()){ \t \t \t返回$此 - >重定向($这 - > Auth->重定向()); \t} \t \t $ this-> Session-> setFlash('Invalid Username or Password please try again'); \t} } – 2014-10-17 20:25:23
Controller :: $ data'仍然可用([** via magic properties **](https://github.com/cakephp/cakephp/blob/2.5.4/lib/Cake/Controller) /Controller.php#L395))以达到向后兼容的目的。 – ndm 2014-10-17 21:09:54