简体   繁体   English

带有电子邮件确认的 Django djoser 用户注册

[英]Django djoser user registration with email confirmation

I'm using Django and djoser as backend for a mobile app.我使用 Django 和 djoser 作为移动应用程序的后端。

When I make following POST request:当我发出以下 POST 请求时:

curl -X POST http://127.0.0.1:8000/auth/users/ --data 'username=myusername&email=myemail&password=mypwd'

I receive an email to myemail with the activation link with the proper uid and token.我收到一封发送到 myemail 的电子邮件,其中包含带有正确 uid 和令牌的激活链接。

Then I try to activate the user by doing:然后我尝试通过执行以下操作来激活用户:

curl -X POST http://127.0.0.1/auth/users/activation/ --data 'uid=myuid&token=mytoken'

After this I get a 404 NOT FOUND response.在此之后,我收到 404 NOT FOUND 响应。 Djoser documentation says the activation endpoint is /users/activation/. Djoser 文档说激活端点是 /users/activation/。

My urls.py is as follows:我的 urls.py 如下:

from django.contrib import admin
from django.urls import include, path, re_path


urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('api.urls')),
    re_path(r'^auth/', include('djoser.urls')),
]

Does anybody know what I'm doing wrong?有谁知道我做错了什么?

Thank you so much for your support!非常感谢你的支持!

I already found my mistake, it is so silly.我已经发现了我的错误,这太愚蠢了。 I come back here just for the record.我回到这里只是为了记录。

curl -X POST http://127.0.0.1/auth/users/activation/ --data 'uid=myuid&token=mytoken'

The URL used for the activation was not specifing the PORT.用于激活的 URL 未指定端口。

It should be like as follows(in my case):它应该如下所示(在我的情况下):

curl -X POST http://127.0.0.1:8000/auth/users/activation/ --data 'uid=myuid&token=mytoken'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM