【问题标题】:Unsure of how to manage email configurations不确定如何管理电子邮件配置
【发布时间】:2020-03-24 15:39:21
【问题描述】:

我正在尝试使用 Djoser 创建重置密码功能。我成功地访问了我的 API 的 auth/users/reset_password/ 端点,然后它按预期发送了一封电子邮件。但是问题出现在电子邮件的内容中。它发送重定向链接到我的 api,而不是我的前端。

请注意,任何 都只是隐藏了一个变量,实际上并没有像那样显示

以下是电子邮件的示例:

You're receiving this email because you requested a password reset for your user account at <api>.

Please go to the following page and choose a new password: <api>/reset-password/confirm/<uid>/<token>

Your username, in case you've forgotten: <username>

Thanks for using our site!

The <api> team

这封电子邮件的目标是将用户发送到我的前端上的/reset-password/confirm/ url,而不是我的 api 上,目前正在发生这种情况。

这是我的 DJOSER 设置:

DJOSER = {
'DOMAIN': '<frontend>',
'SITE_NAME': '<site-name>',
'PASSWORD_RESET_CONFIRM_URL': 'reset-password/confirm/{uid}/{token}',
}

DOMAIN 设置的预期行为是更改放置在电子邮件中的链接,但事实并非如此。我似乎无法在文档中找到对这个特定问题的参考。

非常感谢这里的任何帮助,谢谢。

【问题讨论】:

    标签: django django-rest-framework djoser


    【解决方案1】:

    我想通了:

    由于Djoser 扩展包django-templated-mail,变量DOMAINSITE_NAME 必须覆盖django-templated-mail 设置而不是Djoser 的设置。因此,您必须从 Djoser 变量中提取特定于 django-templated-mail 的变量。

    工作设置实际上看起来像:

    DOMAIN = '<frontend>',
    SITE_NAME = '<site-name>',
    DJOSER = {
    'PASSWORD_RESET_CONFIRM_URL': 'reset-password/confirm/{uid}/{token}',
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      • 2012-11-08
      相关资源
      最近更新 更多