diff --git a/services/webapp/code/rosetta/context_processors.py b/services/webapp/code/rosetta/context_processors.py index 7e6e361db2428d42945ac278c2ab319378a45393..67c443563eb3182827d34ecb957a21baa94eb596 100644 --- a/services/webapp/code/rosetta/context_processors.py +++ b/services/webapp/code/rosetta/context_processors.py @@ -2,8 +2,17 @@ import os from django.conf import settings def export_vars(request): data = {} + + # Set open id connect enabled or not if settings.OIDC_RP_CLIENT_ID: data['OPENID_ENABLED'] = True else: - data['OPENID_ENABLED'] = False + data['OPENID_ENABLED'] = False + + # Set invitation code required or not + if settings.INVITATION_CODE: + data['INVITATION_CODE_ENABLED'] = True + else: + data['INVITATION_CODE_ENABLED'] = False + return data \ No newline at end of file diff --git a/services/webapp/code/rosetta/core_app/templates/register.html b/services/webapp/code/rosetta/core_app/templates/register.html index 26d8bd4b7eddafacf71b973000b50fe0d6e9e3f1..8a7ca29c40c387d7f64a2b5241ff8bb868d2218f 100644 --- a/services/webapp/code/rosetta/core_app/templates/register.html +++ b/services/webapp/code/rosetta/core_app/templates/register.html @@ -7,7 +7,7 @@ <div class="container"> <div class="dashboard"> - <div class="span8 offset2" style="font-size:18px"> + <div class="span8 offset2"> <h1>Register</h1> <hr> @@ -41,7 +41,13 @@ <p><b>Welcome to Rosetta!</b></p> - <p>We are now in closed beta testing, which means that we can only accept invite-based new users. If you have an invitation code, you can sign up right now. Otherwise, please contact the support ot get one. + <p> + {% if INVITATION_CODE_ENABLED %} + We are now in closed beta testing, which means that we can only accept invite-based new users. If you have an invitation code, you can sign up right now. Otherwise, please contact the support to get one. + {% else %} + Enter your email address and choose a password to register on the platform. + {% endif %} + </p> <br/> <br/> @@ -51,7 +57,9 @@ {% csrf_token %} <input type="email" class="form-control" placeholder="Email" name='email' required autofocus> <input type="password" class="form-control" placeholder="Password" name='password' required> + {% if INVITATION_CODE_ENABLED %} <input type="text" class="form-control" placeholder="Invitation code" name='invitation' value='' required autofocus> + {% endif %} <input type='submit' class="btn btn-lg ha-btn-lg" value='Go' /> </form> </div> diff --git a/services/webapp/code/rosetta/core_app/views.py b/services/webapp/code/rosetta/core_app/views.py index 617dec595f6890247fef7d223426dd3c30a99d67..3de2dd6e1a811aaa4e7aafb95041f9f87647b1fa 100644 --- a/services/webapp/code/rosetta/core_app/views.py +++ b/services/webapp/code/rosetta/core_app/views.py @@ -152,8 +152,9 @@ def register_view(request): password = request.POST.get('password') invitation = request.POST.get('invitation') - if invitation != os.environ.get('INVITATION_CODE', 'Rosetta'): - raise ErrorMessage('Wrong invitation code') + if settings.INVITATION_CODE: + if invitation != settings.INVITATION_CODE: + raise ErrorMessage('Wrong invitation code') if '@' not in email: raise ErrorMessage('Detected invalid email address') diff --git a/services/webapp/code/rosetta/settings.py b/services/webapp/code/rosetta/settings.py index 39b06b3c2ce927cb83ec8c6bcb8defe750681296..e3badd8397ed37a8b8811938f4027b587d816c7c 100644 --- a/services/webapp/code/rosetta/settings.py +++ b/services/webapp/code/rosetta/settings.py @@ -226,6 +226,9 @@ LOGGING = { # Local user data dir LOCAL_USER_DATA_DIR = os.environ.get('LOCAL_USER_DATA_DIR', '/data') +# Invitation code if any +INVITATION_CODE = os.environ.get('INVITATION_CODE', None) + #=============================== # Auth