14

I'm trying to use allauth and rest-auth in my project and try to use the built-in function in allauth to do email verification but this what I get :

Link to screenshot of what I get

and here is my code

settings.py

ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_REQUIRED = True

urls.py

urlpatterns = [
re_path(r'^', include('rest_auth.urls')),
re_path(r'^registration/', include('rest_auth.registration.urls')),
]
David Buck
  • 3,752
  • 35
  • 31
  • 35
Fady Alfred
  • 564
  • 1
  • 4
  • 18
  • Have you read http://django-rest-auth.readthedocs.io/en/latest/faq.html?highlight=account_confirm_email? – dukebody Jan 22 '18 at 22:22
  • Sorry, see https://github.com/Tivix/django-rest-auth/issues/292#issuecomment-355099829 and related. – dukebody Jan 22 '18 at 22:26
  • the named url "account_email_verification_sent" isn't included in either of [`rest_auth.urls`](https://github.com/Tivix/django-rest-auth/blob/v0.9.3/rest_auth/urls.py) and [`rest_auth.registration.urls`](https://github.com/Tivix/django-rest-auth/blob/v0.9.3/rest_auth/registration/urls.py). – Oluwafemi Sule Jan 23 '18 at 07:16
  • You want to include `django_allauth` [`account.urls`](https://github.com/pennersr/django-allauth/blob/master/allauth/account/urls.py) – Oluwafemi Sule Jan 23 '18 at 07:19

2 Answers2

24

I found the solution, I have to add a URL to be able to make a post request to the backend to send an email, with the URL with regex which has the token that will verify the account and URLs, and add a URL for login with name account_login and URL for register with name account_signup and be like this :

from rest_auth.registration.views import VerifyEmailView, RegisterView


urlpatterns = [
path('', include('rest_auth.urls')),
path('login/', LoginView.as_view(), name='account_login'),
path('registration/', include('rest_auth.registration.urls')),
path('registration/', RegisterView.as_view(), name='account_signup'),
re_path(r'^account-confirm-email/', VerifyEmailView.as_view(),
     name='account_email_verification_sent'),
re_path(r'^account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(),
     name='account_confirm_email'),

]
Fady Alfred
  • 564
  • 1
  • 4
  • 18
0

I had the same issue but I already had set up the URL for the email confirmation but I forgot about the name parameter it is mandatory

from django.conf.urls import url, include

from dj_rest_auth.registration.views import VerifyEmailView

urlpatterns = [
    url('auth/', include('dj_rest_auth.urls')),
    url('auth/registration/', include('dj_rest_auth.registration.urls')),
    url('auth/account-confirm-email/', VerifyEmailView.as_view(), name='account_email_verification_sent'),    
]
´´´
escaper01
  • 1
  • 1