Django. DJ_REST_AUTH redirects to login page after email confirmation

31 Views Asked by At

As I want my app to be REST app I don't want users to be redirected to login page after successful email confirmation. I use following:

settings:

ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_CONFIRM_EMAIL_ON_GET = True

installed apps:

APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites'
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    "rest_framework",
    "rest_framework.authtoken",
    "dj_rest_auth",
    "dj_rest_auth.registration",
    'accounts',
]

and urls:

from django.urls import path, include
from dj_rest_auth.registration.views import VerifyEmailView, ConfirmEmailView

urlpatterns = [
    path("", include("dj_rest_auth.urls")),
    path(
        'signup/account-confirm-email/<str:key>/',
        ConfirmEmailView.as_view(),
        name="account_confirm_email",
    ),
    path("signup/", include("dj_rest_auth.registration.urls")),
    path('signup/account-confirm-email/',
         VerifyEmailView.as_view(),
         name='account_email_verification_sent'),
]

The registration works, I get an email with a link to confirm. I click and it redirects me to login page which as it is REST doesn't exists.

I belive that it is allauth responsible for this redirection as I haven't found any settings in dj_rest_auth

What I can see in the logs is just:

Not Found: /accounts/login/

I expect there to be some way to redirect to page that informs about the result of verification but I can't find anything in the documentation. Do I need to make my own ConfirmEmailView doesn't redirects but returns page with the result?

0

There are 0 best solutions below