1

我使用 CodeIgniter + Tank Auth。只有代码http://localhost/XXXXXXXX/auth/forgot_password不起作用。结果总是:“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明进行操作。”

注册和激活都可以。

4

4 回答 4

4

一些可能的问题:

  • Cookie 设置不正确。检查您的 cookie 设置,并进行测试以确保您可以设置和读取 cookie。(如果不使用 cookie 进行重置,这可能无效)
  • 重置密码密钥已过期或未正确设置。在点击链接之前检查数据库以查看 hte 值是否正确,并检查您$config['forgot_password_expire']的 Tank Auth。
  • 您可能在电子邮件中链接到错误的 URL。这看起来不对:

    http://localhost/XXXXXXXX/auth/forgot_password

    它应该是这样的:

    http://localhost/auth/forgot_password/XXXXXXXX

不要阻止您使用 Tank Auth,但如果您仍处于早期阶段,我可以建议您尝试使用Ion_Auth 。我相信它也可以在PyroCMS中使用,如果这增加了任何功劳的话。

于 2011-05-07T10:57:43.580 回答
2

如果你的 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 段)。

于 2011-07-13T23:31:43.833 回答
1

它可能是用户模型函数“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;
}
于 2012-02-04T17:02:04.980 回答
1

在主 index.php 中,您必须定义一个时区。例子:

date_default_timezone_set('Europe/Paris');

这将确保以下检查具有相同时区的所有日期

$this->db->where('UNIX_TIMESTAMP(new_password_requested) >', time() - $expire_period);
于 2012-09-30T05:18:50.770 回答