8

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

briflan26
  • 101
  • 1
  • 6
  • 1
    Possible duplicate of [How do I use the built in password reset/change views with my own templates](https://stackoverflow.com/questions/388800/how-do-i-use-the-built-in-password-reset-change-views-with-my-own-templates) – Arpit Solanki Aug 14 '17 at 15:30
  • https://stackoverflow.com/questions/24935271/django-custom-user-email-account-verification – Arpit Solanki Aug 14 '17 at 15:32

2 Answers2

0

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.

Devesh Pradhan
  • 149
  • 1
  • 6
0

For anyone still looking for solutions, django-allauth is a good choice. you can override PASSWORD_RESET_CONFIRM_SERIALIZER to make the user active.