1

I use Django all_auth and rest_auth for a backend service of a mobile app. I integrated the registration and login API and all works fine.

Now I have to integrate the e-mail address validation logic.

After the registration (without social), I have to send an e-mail with the link that the user will use to validate your account.

I added this configurations into my Django settings:

ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'

Also this works fine. I'm able to receive the e-mail after the registration of a new account. In the received e-mail I have the link to validate the account also.

I would like to have the validation of the e-mail when the user simply will click on the link.

So, I would like to use only the GET HTTP method.

I added, as suggested into the documentation, this setting also:

ACCOUNT_CONFIRM_EMAIL_ON_GET = True

I use this url linked to the all_auth views.

from allauth.account.views import ConfirmEmailView
url(r'^account-confirm-email/', ConfirmEmailView.as_view(), name='account_email_verification_sent'),
url(r'^account-confirm-email/(?P<key>[-:\w]+)/$', ConfirmEmailView.as_view(), name='account_confirm_email'),

But, if I try to click on the link from the received mail, I obtain this error:

KeyError at /account-confirm-email/NzU:1hjl8A:z5Riy8Bjv_h0zJQtoYKuTkKvRLk/
'key'

/allauth/account/views.py in get
            self.object = self.get_object() ...
▶ Local vars
/allauth/account/views.py in get_object
        key = self.kwargs['key'] ...
▶ Local vars

This seams that setting is not sufficient to have the possibility to use the e-mail validation with GET method.

Have I to overwrite the custom Django view for this?

1 Answer 1

1

Looks like you're using the same view two times where you should use another view class. Following change should fix it:

from allauth.account.views import ConfirmEmailView, EmailVerificationSentView

# ...

url(
    r'^account-confirm-email/',
    EmailVerificationSentView.as_view(),  # This is changed
    name='account_email_verification_sent',
),
url(
    r'^account-confirm-email/(?P<key>[-:\w]+)/$',
    ConfirmEmailView.as_view(),
    name='account_confirm_email',
),

# ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.