Search code examples
pythondjangodjango-allauth

Django allauth Redirect to email verification after social signup


I use Twitter for main signup/login and I would like to redirect to 'accounts/email' link after social signup because I want to force new user to provide their emails. I've found same question and answer from @Anzel

from allauth.socialaccount.adapter import DefaultSocialAccountAdapter

class SocialAccountAdapter(DefaultSocialAccountAdapter):
      def save_user(self, request, sociallogin, form=None):
          super(DefaultSocialAccountAdapter, self).save_user(request, sociallogin, form=form)
          return redirect('/accounts/email/') 

but the answer didn't work for me and got this

AttributeError at /accounts/twitter/login/callback/

'super' object has no attribute 'save_user'

Request Method:     GET
Request URL:    http://localhost:8000/accounts/twitter/login/callback/?oauth_token=HSowSgAAAAAAuTblAAABVrLCOpE&oauth_verifier=cVrwyB2Vfk2Lgsrwg5fqE0wyzrfnwJ3H
Django Version:     1.9.2
Exception Type:     AttributeError
Exception Value:    

'super' object has no attribute 'save_user'

Solution

  • In setting.py I only add those two lines and forgot about the adapter :

    SOCIALACCOUNT_AUTO_SIGNUP = True
    SOCIALACCOUNT_EMAIL_REQUIRED = True
    

    and now after signup or login it redircts new users only to /accounts/social/signup/ and this view actually force the user to submit his eamil and process to a verification.