我使用 CodeIgniter + Tank Auth。只有代码http://localhost/XXXXXXXX/auth/forgot_password不起作用。结果总是:“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明进行操作。”
注册和激活都可以。
我使用 CodeIgniter + Tank Auth。只有代码http://localhost/XXXXXXXX/auth/forgot_password不起作用。结果总是:“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明进行操作。”
注册和激活都可以。
一些可能的问题:
$config['forgot_password_expire']
的 Tank Auth。您可能在电子邮件中链接到错误的 URL。这看起来不对:
http://localhost/XXXXXXXX/auth/forgot_password
它应该是这样的:
http://localhost/auth/forgot_password/XXXXXXXX
不要阻止您使用 Tank Auth,但如果您仍处于早期阶段,我可以建议您尝试使用Ion_Auth 。我相信它也可以在PyroCMS中使用,如果这增加了任何功劳的话。
如果你的 URL 中的 XXXXXXXX 表明你在 /auth/ 之前有一个额外的 URI 段,你应该改变这个:
function reset_password()
{
$user_id = $this->uri->segment(3);
$new_pass_key = $this->uri->segment(4);
对此:
function reset_password()
{
$user_id = $this->uri->segment(4);
$new_pass_key = $this->uri->segment(5);
注意 $this->uri->segment() 中的不同数字。在 /auth/ 之前有一个额外的段,您的用户 ID 和激活码将作为参数传递到第 4 和第 5 段(而不是 Tank Auth 假定的第 3 和第 4 段)。
它可能是用户模型函数“can_reset_password”中数据库中的时间戳使用 UNIX_TIMESTAMP(new_password_requested)
您可以回显 $user_id 和 $new_pass_key 如果它们是正确的,那么问题在于时间比较。修复 url 以始终获取最后两个段
$break =$this->uri->total_segments();
$new_pass_key= $this->uri->segment($break);
$user_id= $this->uri->segment($break-1);
对于时间戳试试这个用户模型中的函数reset_password
function reset_password($user_id, $new_pass, $new_pass_key, $expire_period = 900)
{
$this->load->helper('date');
$this->db->set('password', $new_pass);
$this->db->set('new_password_key', NULL);
$this->db->set('new_password_requested', NULL);
$this->db->where('id', $user_id);
$this->db->where('new_password_key', $new_pass_key);
$this->db->where('UNIX_TIMESTAMP(new_password_requested) >=',mysql_to_unix( time() - $expire_period));
$this->db->update($this->table_name);
return $this->db->affected_rows() > 0;
}
在主 index.php 中,您必须定义一个时区。例子:
date_default_timezone_set('Europe/Paris');
这将确保以下检查具有相同时区的所有日期
$this->db->where('UNIX_TIMESTAMP(new_password_requested) >', time() - $expire_period);