【问题标题】:Django reset password: invalid tokenDjango重置密码:无效令牌
【发布时间】:2020-07-30 07:49:31
【问题描述】:

我已将我的 Django 项目部署在生产环境中,并使用 Django 身份验证重置密码

我收到一封带有链接的电子邮件,但我收到消息“无效令牌”,这意味着该链接无效

Settings.py

ALLOWED_HOSTS = ['192.xxx.xx.xx','http://example.com/','https://example.com/'] #example.com replace by my real domain
CSRF_COOKIE_SECURE = True
CSRF_TRUSTED_ORIGINS = ['example.com']

password_reset_email.html

Une demande de modification de mot de passe a été demandé par {{ email }}. 
Veuillez suivre ce lien :
{{ protocol}}://example.com{% url 'password_reset_confirm' uidb64=uid token=token %}


PS : Merci de ne pas répondre à cet email

【问题讨论】:

    标签: django authentication


    【解决方案1】:

    如果您使用的是CSRF_COOKIE_SECURE = True,那么您的 URL 必须是 https。

    您可以阅读更多关于它的信息here

    【讨论】:

      猜你喜欢
      • 2015-02-21
      • 2016-02-22
      • 1970-01-01
      • 2016-05-03
      • 2015-04-28
      • 2020-12-15
      • 2017-02-03
      • 2017-08-12
      • 2019-09-11
      相关资源
      最近更新 更多