0
任何人都可以看到此行的一個問題:在使用令牌時Use of undefined constant CAKE_SESSION_STRING - assumed 'CAKE_SESSION_STRING'
CakePHP的MD5和蛋糕會話串
它仍然創建了一個令牌,但給出了錯誤,然後:$emailtoken = md5($user['User']['password'].CAKE_SESSION_STRING);
因爲它提供了以下錯誤它說,它是無效的:/
以下是完整的功能:
function admin_resetpassword ($token = null)
{
// User submits their email address
if (!empty($this->data['User']['email']))
{
// user submitted initial form
$user = $this->User->findByEmail($this->data['User']['email']);
if (empty($user))
{
$this->Session->setFlash('Unknown email.');
return;
}
else
{
$emailtoken = md5($user['User']['password'].CAKE_SESSION_STRING);
// send email (temp flash to test code)
$this->Session->setFlash($emailtoken);
return;
}
}
// If the token is not empty on the url
if (!empty($token))
{
$user = $this->User->find(array("MD5(User.password + '".CAKE_SESSION_STRING."')"=>$token));
if (empty($user))
{
$this->Session->setFlash('Invalid token.');
return;
}
if (!empty($this->data['User']['password']))
{
$user['User']['password'] = $this->data['User']['password'];
$this->user->save($user);
$this->Session->setFlash('New password set.');
$this->redirect('/');
}
$this->set('token', $token);
$this->render('newpassword2');
}
}