mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
Feature: OIDC & social authentication (#5190)
--------- Co-authored-by: Moritz Pflanzer <moritz@chickadee-engineering.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
30
src/paperless/adapter.py
Normal file
30
src/paperless/adapter.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class CustomAccountAdapter(DefaultAccountAdapter):
|
||||
def is_open_for_signup(self, request):
|
||||
allow_signups = super().is_open_for_signup(request)
|
||||
# Override with setting, otherwise default to super.
|
||||
return getattr(settings, "ACCOUNT_ALLOW_SIGNUPS", allow_signups)
|
||||
|
||||
|
||||
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
|
||||
def is_open_for_signup(self, request, sociallogin):
|
||||
allow_signups = super().is_open_for_signup(request, sociallogin)
|
||||
# Override with setting, otherwise default to super.
|
||||
return getattr(settings, "SOCIALACCOUNT_ALLOW_SIGNUPS", allow_signups)
|
||||
|
||||
def get_connect_redirect_url(self, request, socialaccount):
|
||||
"""
|
||||
Returns the default URL to redirect to after successfully
|
||||
connecting a social account.
|
||||
"""
|
||||
url = reverse("base")
|
||||
return url
|
||||
|
||||
def populate_user(self, request, sociallogin, data):
|
||||
# TODO: If default global permissions are implemented, should also be here
|
||||
return super().populate_user(request, sociallogin, data) # pragma: no cover
|
Reference in New Issue
Block a user