danihodovic / django-allauth-ui

Nice looking templates for django-allauth
https://django-allauth-ui.hodovi.ch
MIT License
202 stars 24 forks source link

Add signup_closed, for when adaptor disallows signup #41

Closed fzzylogic closed 5 months ago

fzzylogic commented 5 months ago

Super helpful project, thanks for sharing!

This template comes into play if a custom adaptor is used to disallow manual signup, e.g.

# adapters.py
from allauth.account.adapter import DefaultAccountAdapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter

class CustomAccountAdapter(DefaultAccountAdapter):
    def is_open_for_signup(self, request):
        return False

class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
    def is_open_for_signup(self, request, sociallogin):
        return True

# settings.py
ACCOUNT_ADAPTER = 'myproject.myapp.adapter.CustomAccountAdapter'
SOCIALACCOUNT_ADAPTER = 'myproject.myapp.adapter.CustomSocialAccountAdapter'

For the above, signup using configured social accounts would be allowed, but manual signup would be disallowed and clicking 'signup' on any page would display the template included in this pull request (handled by django-allauth automatically based on the return value of is_open_for_signup).

danihodovic commented 5 months ago

Released as 0.2.2