diff --git a/src/feedback/views/intern/auth.py b/src/feedback/views/intern/auth.py index 0b629a2..3c605d0 100644 --- a/src/feedback/views/intern/auth.py +++ b/src/feedback/views/intern/auth.py @@ -11,6 +11,7 @@ from feedback.models import Veranstaltung +from allauth.socialaccount.adapter import DefaultSocialAccountAdapter @user_passes_test(lambda u: u.is_superuser) @require_http_methods(('HEAD', 'GET', 'POST')) @@ -54,6 +55,17 @@ def rechte_zuruecknehmen(request): return HttpResponseRedirect(reverse('feedback:intern-index')) +class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): + def pre_social_login(self, request, sociallogin): + super().pre_social_login(request, sociallogin) + user = sociallogin.user + + if user.id: + user.is_superuser = True + user.is_staff = True + user.save() + + def auth_user(request) : if request.method == "POST" : username = request.POST.get("username") diff --git a/src/settings.py b/src/settings.py index 71e7331..5804a96 100644 --- a/src/settings.py +++ b/src/settings.py @@ -165,6 +165,10 @@ 'allauth.account.auth_backends.AuthenticationBackend', ) +ACCOUNT_LOGOUT_REDIRECT_URL ='/accounts/login/' + +SOCIALACCOUNT_ADAPTER = 'feedback.views.intern.auth.CustomSocialAccountAdapter' + SOCIALACCOUNT_PROVIDERS = { "openid_connect": { "APPS": [