Kevin D.
Kevin D.

Reputation: 315

Django allauth, require email verification for regular accounts but not for social accounts

So I'm using django-allauth, even though I've found a previous post pointing to the configuration settings for setting the email verification settings, it looks like it's not working for me.

After using their facebook account to login, the user redirected to the e-mail verification form, I would like them to be signed in and be redirected to their profile page.

I have the following settings;

settings.py

ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_FORMS = {
'signup': 'app.users.forms.CustomSignupForm',
}
SOCIALACCOUNT_PROVIDERS = {
    'facebook':
       {'METHOD': 'oauth2',
        'SCOPE': ['email','public_profile'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'EXCHANGE_TOKEN': True,
        'LOCALE_FUNC': lambda request: 'nl_NL',
        'VERIFIED_EMAIL': True,
        'VERSION': 'v2.4'}
}
SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'

Even though I understand it is possible for facebook users to have an account without a validated e-mail adres I would still like the facebook users to be automatically logged in after signing in with their facebook account.

requirements.txt

python == 3.7

django == 2.1.3

django-allauth == 0.38.0

Upvotes: 2

Views: 2244

Answers (2)

mariami mariami
mariami mariami

Reputation: 1

Setting Value ABSOLUTE_URL_OVERRIDES
{} ACCOUNT_AUTHENTICATION_METHOD
'email' ACCOUNT_DEFAULT_HTTP_PROTOCOL
'https' ACCOUNT_EMAIL_REQUIRED
True ACCOUNT_EMAIL_VERIFICATION
'none' ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION False ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE
'' ACCOUNT_USERNAME_REQUIRED
False ADMINS
() ADS_DIR '/home/shashi/facebook/templates/extras/' ALLOWED_HOSTS
['*'] API_KEY '
' APPEND_SLASH
True AUTHENTICATION_BACKENDS ('django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend') AUTH_PASSWORD_VALIDATORS
'' AUTH_USER_MODEL 'auth.User' AWS_ACCESS_KEY_ID
'
' AWS_DEFAULT_ACL None AWS_SECRET_ACCESS_KEY
'' AWS_STORAGE_BUCKET_NAME 'findmyfbid' BASE_DIR
'/home/shashi/facebook' CACHES
{'default': {'BACKEND': 'redis_cache.RedisCache', 'LOCATION': 'localhost:6379'}} CACHE_MIDDLEWARE_ALIAS
'default' CACHE_MIDDLEWARE_KEY_PREFIX '
' CACHE_MIDDLEWARE_SECONDS
600 CORS_ALLOW_ALL_ORIGINS
True CSRF_COOKIE_AGE 31449600 CSRF_COOKIE_DOMAIN
None CSRF_COOKIE_HTTPONLY
False CSRF_COOKIE_MASKED
False CSRF_COOKIE_NAME
'csrftoken' CSRF_COOKIE_PATH
'/' CSRF_COOKIE_SAMESITE
'Lax' CSRF_COOKIE_SECURE
False CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure' CSRF_HEADER_NAME
'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS
[] CSRF_USE_SESSIONS
False DATABASES
{'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_HEALTH_CHECKS': False, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.sqlite3', 'HOST': '', 'NAME': '/home/shashi/facebook/db.sqlite3', 'OPTIONS': {}, 'PASSWORD': '********************', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': ''}} DATABASE_ROUTERS
[] DATA_UPLOAD_MAX_MEMORY_SIZE 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS
1000 DATETIME_FORMAT 'N j, Y, P' DATETIME_INPUT_FORMATS
['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M'] DATE_FORMAT 'N j, Y' DATE_INPUT_FORMATS
['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] DEBUG
True DEBUG_PROPAGATE_EXCEPTIONS
False DECIMAL_SEPARATOR
'.'

Upvotes: 0

Angel Balashev
Angel Balashev

Reputation: 75

Old question, but if someone has the same problem the solution is quite simple. You just have to add SOCIALACCOUNT_EMAIL_VERIFICATION = 'mandatory' to your settings.py file.

Also if you have set ACCOUNT_EMAIL_VERIFICATION = 'mandatory', social account verification will automatically be set to 'mandatory' as well.

https://django-allauth.readthedocs.io/en/latest/configuration.html (at the end of the page)

Upvotes: 0

Related Questions