简体   繁体   English

Django - 身份验证,注册电子邮件确认

[英]Django - authentication, registration with email confirmation

I'm looking at the API for authentication 我正在查看用于身份验证的API

https://docs.djangoproject.com/en/1.3/topics/auth/ https://docs.djangoproject.com/en/1.3/topics/auth/

I can't seem to find information on simple user registration form that would send confirmation email as it is the usual way on web sites. 我似乎无法找到有关简单用户注册表单的信息,因为它是发送确认电子邮件,因为它是网站上的常用方式。

I guess I could do this: 我想我能做到这一点:

1) Display a form 2) User enters info and submits 3) Save user as inactive, with a confirmation code 4) Send a link with confirmation code 5) User clicks a confirmation link and becomes active 1)显示表格2)用户输入信息并提交3)将用户保存为非活动状态,并带有确认码4)发送带有确认码的链接5)用户点击确认链接并激活

It doesn't seem that difficult but I have a feeling this might be done already, and also there are quite a few edge cases that would need to be considered. 这似乎并不困难,但我有一种感觉,这可能已经完成,并且还有很多边缘情况需要考虑。

It's not built into Django. 它没有内置到Django中。 There is a reusable app called django-allauth , which will fit your needs. 有一个名为django-allauth的可重用应用程序,它将满足您的需求。

An app called django-registration used to be recommended, but that is now unmaintained and out of date. 曾经推荐过一个名为django-registration的应用程序,但现在这个应用程序尚未维护且已过时。

Editor note : django-registration is not unmaintained as of December 2016. 编者注 :截至2016年12月,django-registration并未维持不变。

While django-registration used to be the registration system du jour, it has been abandoned by the maintainer and doesn't work on Django 1.6 without patching . 虽然django-registration曾经是注册系统du jour,但它已被维护者抛弃,并且在没有修补的情况下无法在Django 1.6上运行

Try maybe django-allauth - I would have used it if I had known about it when I was looking. 尝试一下django-allauth - 如果我在看的时候知道它,我会用它。 (As it turned out, I found this question first and used django-registration, wasting a lot of time.) (事实证明,我首先发现了这个问题并使用了django-registration,浪费了很多时间。)

EDIT 10/2016: Looks like django-registration is maintained again. 编辑10/2016:看起来再次维护django-registration。 It's on GitHub now: https://github.com/ubernostrum/django-registration 它现在在GitHub上: https//github.com/ubernostrum/django-registration

You can do this: 你可以这样做:

  • Define a function to activate the user (ie def activate(request)) 定义激活用户的功能(即def激活(请求))
    • Configure in the url.py the route to that function (ie /activate/) 在url.py中配置到该函数的路由(即/ activate /)
  • Create a form to register user 创建一个表单来注册用户
  • Create the post function to create the user 创建post函数以创建用户
    • When you create the user set field 'is_active' to 0. 将用户设置字段“is_active”创建为0时。
    • In the same function send the email with a link inside, this link must have the target as the configured route 在同一个函数中,发送带有链接的电子邮件,此链接必须将目标作为已配置的路由

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

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