Skip to content
Snippets Groups Projects
Commit 7393c7ba authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Improved handling of the invitation code. Minor fixes.

parent 6d5e7554
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,17 @@ import os ...@@ -2,8 +2,17 @@ import os
from django.conf import settings from django.conf import settings
def export_vars(request): def export_vars(request):
data = {} data = {}
# Set open id connect enabled or not
if settings.OIDC_RP_CLIENT_ID: if settings.OIDC_RP_CLIENT_ID:
data['OPENID_ENABLED'] = True data['OPENID_ENABLED'] = True
else: 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 return data
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<div class="dashboard"> <div class="dashboard">
<div class="span8 offset2" style="font-size:18px"> <div class="span8 offset2">
<h1>Register</h1> <h1>Register</h1>
<hr> <hr>
...@@ -41,7 +41,13 @@ ...@@ -41,7 +41,13 @@
<p><b>Welcome to Rosetta!</b></p> <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/>
<br/> <br/>
...@@ -51,7 +57,9 @@ ...@@ -51,7 +57,9 @@
{% csrf_token %} {% csrf_token %}
<input type="email" class="form-control" placeholder="Email" name='email' required autofocus> <input type="email" class="form-control" placeholder="Email" name='email' required autofocus>
<input type="password" class="form-control" placeholder="Password" name='password' required> <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> <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' /> <input type='submit' class="btn btn-lg ha-btn-lg" value='Go' />
</form> </form>
</div> </div>
......
...@@ -152,8 +152,9 @@ def register_view(request): ...@@ -152,8 +152,9 @@ def register_view(request):
password = request.POST.get('password') password = request.POST.get('password')
invitation = request.POST.get('invitation') invitation = request.POST.get('invitation')
if invitation != os.environ.get('INVITATION_CODE', 'Rosetta'): if settings.INVITATION_CODE:
raise ErrorMessage('Wrong invitation code') if invitation != settings.INVITATION_CODE:
raise ErrorMessage('Wrong invitation code')
if '@' not in email: if '@' not in email:
raise ErrorMessage('Detected invalid email address') raise ErrorMessage('Detected invalid email address')
......
...@@ -226,6 +226,9 @@ LOGGING = { ...@@ -226,6 +226,9 @@ LOGGING = {
# Local user data dir # Local user data dir
LOCAL_USER_DATA_DIR = os.environ.get('LOCAL_USER_DATA_DIR', '/data') 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 # Auth
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment