From f23c3ecc4c93a8f4c6e3cb0694ffa40317cf93b7 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 10 Jun 2020 21:14:43 +0000 Subject: [PATCH] Add a bypass code to allow registration outside Protospace --- apiserver/apiserver/api/serializers.py | 8 +++++++- apiserver/apiserver/secrets.py.example | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index ee7b2fe..b7c0868 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -405,7 +405,13 @@ class MyRegisterSerializer(RegisterSerializer): def custom_signup(self, request, user): data = request.data - if not utils.is_request_from_protospace(request): + if secrets.REGISTRATION_BYPASS: + bypass_code = data.get('bypass_code', None) + allow_bypass = secrets.REGISTRATION_BYPASS == bypass_code + else: + allow_bypass = False + + if not allow_bypass and not utils.is_request_from_protospace(request): logger.info('Request not from protospace') user.delete() raise ValidationError(dict(non_field_errors='Can only register from Protospace.')) diff --git a/apiserver/apiserver/secrets.py.example b/apiserver/apiserver/secrets.py.example index 2e0cca7..305f252 100644 --- a/apiserver/apiserver/secrets.py.example +++ b/apiserver/apiserver/secrets.py.example @@ -12,6 +12,13 @@ ADMIN_RANDOM = '' # head /dev/urandom | base32 | head -c 16 IPN_RANDOM = '' +# Registration bypass code +# Allows people to register outside of protospace +# Set this to random characters +# For example, use the output of this: +# head /dev/urandom | base32 | head -c 16 +REGISTRATION_BYPASS = '' + # Django secret key # Set this to random characters # For example, use the output of this: