Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check that SOCIALACCOUNT_PROVIDERS don't use kobo as ID #4653

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions kobo/apps/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
from django.apps import AppConfig
from django.conf import settings
from django.core.checks import Error, register


# Config to set custom name for app in django admin UI
# see https://docs.djangoproject.com/en/4.1/ref/applications/#for-application-authors
class AccountExtrasConfig(AppConfig):
name = "kobo.apps.accounts"
verbose_name = "Account Extras"


@register()
def check_socialaccount_providers(app_configs, **kwargs):
"""
Don't allow `kobo` to be set as the `id` value in `SOCIALACCOUNT_PROVIDERS`
settings because it breaks the login page redirect when language is changed.
"""
errors = []
social_app_ids = [
apps['id']
for apps in settings.SOCIALACCOUNT_PROVIDERS['openid_connect'][
'SERVERS'
]
]
if 'kobo' in social_app_ids:
errors.append(
Error(
f'Please do not use `kobo` as the `id` value in '
'`SOCIALACCOUNT_PROVIDERS` settings.',
hint='`kobo` is not a valid value for this setting.',
obj=settings,
id='kobo.apps.accounts.E001',
)
)
return errors