简体   繁体   English

电子邮件验证和密码重置 - django rest 框架和 angularjs

[英]Email verification and password reset - django rest framework and angularjs

How do I implement the built in views for password-reset in the django.rest.auth and how do I create an email verification system for registration using the django rest framework and angularjs?如何在 django.rest.auth 中实现用于密码重置的内置视图,以及如何使用 django rest 框架和 angularjs 创建用于注册的电子邮件验证系统?

I have been searching for a tutorial or some good documentation that on how to implement django's send_email function in a website using the django rest framework and angular js but I haven't been able to find any.我一直在寻找有关如何使用 django rest 框架和 angular js 在网站中实现 django 的 send_email 功能的教程或一些好的文档,但我一直找不到。

What I need...我需要什么...

  • when a new user registers a url must be generated for them to confirm their email address当新用户注册时,必须为他们生成一个 url 以确认他们的电子邮件地址
  • this url must be automatically sent to the user's given email这个 url 必须自动发送到用户给定的电子邮件
  • after the user is sent to this link and confirms their email address their status must be changed from new_user.is_active = False to new_user.is_active = True在用户被发送到此链接并确认他们的电子邮件地址后,他们的状态必须从 new_user.is_active = False 更改为 new_user.is_active = True

What I have...我有什么...

  • registration form that sends a post request to my register endpoint向我的注册端点发送发布请求的注册表单
    • the new user data is then unpacked, validated, and saved in my register view然后将新用户数据解包、验证并保存在我的注册视图中
  • in settings.py i have added this...在settings.py中我添加了这个...

     EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'myemail@gmail.com' EMAIL_HOST_PASSWORD = 'mypassword' EMAIL_PORT = 587
  • in my urls.py i have added this...在我的 urls.py 中,我添加了这个...

     from django.conf.urls import url from rest_auth.views import PasswordResetView, PasswordResetConfirmView urlpatterns = [ url(r'^password/reset/$', PasswordResetView.as_view(), name='password_reset'), url(r'^password/reset/confirm/$', PasswordResetConfirmView.as_view(), name='password_reset_confirm'), ]

So my question is how do I implement these views and urls to my project and how to I create email confirmation using the from django.core.mail import send_mail所以我的问题是如何在我的项目中实现这些视图和 url,以及如何使用from django.core.mail import send_mail创建电子邮件确认

Thanks in advance提前致谢

After the user fills the registration form you could ask for a verification code.用户填写注册表后,您可以要求提供验证码。 This verification code will be sent to the email address provided in the registration form.此验证码将发送到注册表中提供的电子邮件地址。 On correctly entering the verification code you can set the users to active.正确输入验证码后,您可以将用户设置为活动状态。

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

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