Search code examples
pythondjangoopenidsteampython-social-auth

Why python-social-auth is deleting my first_name and last_name fields every time i login with steam?


It's very strange to happen, does anyone know how to fix it?

All this is because I want to eliminate user creation and just leave external social networks.

I will also implement Twitch.tv, although I have not tested it if it deletes it as well.

Login (Template): Here I just put the button as it appears in the documentation.

<a class="btn btn-steam" href="{% url "social:begin" "steam" %}" role="button"><i class="fa fa-steam" aria-hidden="true"></i> Login with Steam</a>

Login views.py

class UserLogin(TemplateView):
    success_url = 'timeline'
    template_name = 'registration/login.html'

Settings.py

import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1','plxapp.herokuapp.com']
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'easy_thumbnails',
    'social_django',
    'core.apps.CoreConfig',
    'userprofile.apps.UserProfileConfig',
    'posts.apps.PostsConfig',
    'posts.templatetags.custom_filters',
]
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'plaxed.urls'
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'social_django.context_processors.backends',
                'social_django.context_processors.login_redirect',
            ],
        },
    },
]
WSGI_APPLICATION = 'plaxed.wsgi.application'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':     'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Bogota'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
LOGIN_REDIRECT_URL = 'timeline'
import dj_database_url
db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
THUMBNAIL_ALIASES = {
    '': {
        'post': {'size': (555, 0), 'crop': 'smart', 'upscale' : True},
        'header': {'size': (1170, 350), 'crop': 'smart', 'upscale' : True},
        'avatar': {'size': (200, 200), 'crop': 'smart', 'upscale' : True},
        'avatar_thumb': {'size': (50, 50), 'crop': 'smart', 'upscale' : True},
    },
}
SOCIAL_AUTH_LOGIN_REDIRECT_URL = 'timeline'
SOCIAL_AUTH_LOGIN_ERROR_URL = 'login'
SOCIAL_AUTH_LOGIN_URL = 'index'
SOCIAL_AUTH_NEW_USER_REDIRECT_URL = 'userprofile_basic'
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = 'timeline'
SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = 'login'
SOCIAL_AUTH_INACTIVE_USER_URL = 'index'
SOCIAL_AUTH_USER_MODEL = 'auth.User'
AUTHENTICATION_BACKENDS = (
    'social_core.backends.open_id.OpenIdAuth',
    'social_core.backends.steam.SteamOpenId',
    'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_PIPELINE = (
    'social_core.pipeline.social_auth.social_details',
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.user.create_user',
    'social_core.pipeline.social_auth.associate_user',
    'social_core.pipeline.social_auth.load_extra_data',
    'social_core.pipeline.user.user_details',
    'social_core.pipeline.social_auth.associate_by_email',
)
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['username', 'first_name', 'email']
SOCIAL_AUTH_STEAM_API_KEY = 'a key'
SOCIAL_AUTH_STEAM_EXTRA_DATA = ['player']

Solution

  • Its a Python Social Auth bug, not solved i change it for django-allauth