简体   繁体   中英

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?

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.

What I need...

  • when a new user registers a url must be generated for them to confirm their email address
  • this url must be automatically sent to the user's given email
  • 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

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...

     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...

     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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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