Tank Auth 忘记密码不起作用

发布于 2024-11-05 18:56:27 字数 231 浏览 0 评论 0原文

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

注册和激活就OK了。

I use CodeIgniter + Tank Auth. Only the code http://localhost/XXXXXXXX/auth/forgot_password doesn't work.
The result always is:
"Your activation key is incorrect or expired. Please check your email again and follow the instructions."

The registration and activation are all right.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

阪姬 2024-11-12 18:56:27

一些可能的问题:

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

    http://localhost/XXXXXXXX/auth/forgot_password

    应该是这样的:

    http://localhost/auth/forgot_password/XXXXXXXX

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

Some likely problems:

  • Cookies are not being set correctly. Check your cookie settings, and do a test to make sure you can set and read cookies. (this may be invalid if cookies are not used for the reset)
  • The reset password key is expired or wasn't set correctly. Check the database to see if hte value is correct before following the link, and check your $config['forgot_password_expire'] in Tank Auth.
  • You may be linking to the wrong URL in your email.
    This doesn't look right:

    http://localhost/XXXXXXXX/auth/forgot_password

    It should be something like:

    http://localhost/auth/forgot_password/XXXXXXXX

Not to discourage you from using Tank Auth, but having used it I can recommend trying Ion_Auth if you are still in the early stages. I believe it's used in PyroCMS as well if that adds any credit.

一笔一画续写前缘 2024-11-12 18:56:27

如果 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 和激活码将作为第四和第五段中的参数传递(而不是 Tank Auth 假定的第三和第四段)。

If the XXXXXXXX in your URL is indicating that you have an extra URI segment before /auth/, you should change this:

function reset_password()
{
    $user_id = $this->uri->segment(3);
    $new_pass_key = $this->uri->segment(4);

to this:

function reset_password()
{
    $user_id = $this->uri->segment(4);
    $new_pass_key = $this->uri->segment(5);

Note the different numbers in $this->uri->segment(). With an extra segment before /auth/, your user id and activation code will be passed as parameters in the 4th and 5th segment (rather than the 3rd and 4th that Tank Auth assumes).

一袭水袖舞倾城 2024-11-12 18:56:27

它可能是您数据库中的时间戳
在用户模型函数“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;
}

it could be the time stamp in your database
in user model function "can_reset_password"
uses a UNIX_TIMESTAMP(new_password_requested)

you could echo $user_id and $new_pass_key if they are correct then the problem is with time comparison.
to fix the the url to always get the last two segments

$break =$this->uri->total_segments();
$new_pass_key= $this->uri->segment($break);
$user_id= $this->uri->segment($break-1);

for the time stamp try this for the function reset_password in users model

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;
}
蓝眼泪 2024-11-12 18:56:27

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

date_default_timezone_set('Europe/Paris');

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

$this->db->where('UNIX_TIMESTAMP(new_password_requested) >', time() - $expire_period);

In the main index.php, you have to define a time zone. Example:

date_default_timezone_set('Europe/Paris');

this will ensure that the following check has all the dates with the same time zone

$this->db->where('UNIX_TIMESTAMP(new_password_requested) >', time() - $expire_period);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文