diff --git a/.env.template b/.env.template index 29078208..36c56980 100644 --- a/.env.template +++ b/.env.template @@ -58,3 +58,10 @@ REVERSE_PROXY_AUTH=0 # see docs for more information https://vabene1111.github.io/recipes/features/authentication/ # SOCIAL_PROVIDERS = allauth.socialaccount.providers.github, allauth.socialaccount.providers.nextcloud, +# Should a newly created user from a social provider get assigned to the default space and given permission by default ? +# ATTENTION: This feature might be deprecated in favor of a space join and public viewing system in the future +# default 0 (false), when 1 (true) users will be assigned space and group +# SOCIAL_DEFAULT_ACCESS = 1 + +# if SOCIAL_DEFAULT_ACCESS is used, which group should be added +# SOCIAL_DEFAULT_GROUP=guest \ No newline at end of file diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 36ab0e54..3069a41f 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -90,6 +90,11 @@ def no_groups(request): def no_space(request): + if settings.SOCIAL_DEFAULT_ACCESS: + request.user.userpreference.space = Space.objects.first() + request.user.userpreference.save() + request.user.groups.add(Group.objects.get(name=settings.SOCIAL_DEFAULT_GROUP)) + return HttpResponseRedirect(reverse('index')) return render(request, 'no_space_info.html') diff --git a/recipes/settings.py b/recipes/settings.py index a14c7c0d..e7310a91 100644 --- a/recipes/settings.py +++ b/recipes/settings.py @@ -26,6 +26,10 @@ SECRET_KEY = os.getenv('SECRET_KEY') if os.getenv('SECRET_KEY') else 'INSECURE_S DEBUG = bool(int(os.getenv('DEBUG', True))) DEMO = bool(int(os.getenv('DEMO', False))) +SOCIAL_DEFAULT_ACCESS = bool(int(os.getenv('SOCIAL_DEFAULT_ACCESS', False))) +SOCIAL_DEFAULT_GROUP = os.getenv('SOCIAL_DEFAULT_GROUP', 'guest') + + INTERNAL_IPS = os.getenv('INTERNAL_IPS').split(',') if os.getenv('INTERNAL_IPS') else ['127.0.0.1'] # allow djangos wsgi server to server mediafiles