Add a bypass code to allow registration outside Protospace

This commit is contained in:
Tanner Collin 2020-06-10 21:14:43 +00:00
parent 84b83baf13
commit f23c3ecc4c
2 changed files with 14 additions and 1 deletions

View File

@ -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.'))

View File

@ -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: