Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env_sample
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ AWS_QUERYSTRING_AUTH=False
# -----------------------------------------------------------------------------
RERUN_SUBMISSION_LIMIT=30

# -----------------------------------------------------------------------------
# Enable or disbale regular email sign-in an sign-up
# -----------------------------------------------------------------------------
ENABLE_SIGN_UP=True
ENABLE_SIGN_IN=True


# # S3 storage example
# STORAGE_TYPE=s3
Expand Down
4 changes: 0 additions & 4 deletions src/apps/profiles/urls_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
urlpatterns = [
url(r'^signup', views.sign_up, name="signup"),
path('login/', views.log_in, name='login'),
# url(r'^user_profile', views.user_profile, name="user_profile"),
# path('login/', auth_views.LoginView.as_view(extra_context=extra_context), name='login'),
# path('login/', views.LoginView.as_view(), name='login'),
# path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('logout/', views.LogoutView.as_view(), name='logout'),
path('password_reset/', views.CustomPasswordResetView.as_view(), name='password_reset'),
path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
Expand Down
6 changes: 6 additions & 0 deletions src/apps/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def activateEmail(request, user, to_email):


def sign_up(request):

# If sign up is not enabled then redirect to login
# this is for security as some users may access sign up page using the url
if not settings.ENABLE_SIGN_UP:
return redirect('accounts:login')

context = {}
context['chahub_signup_url'] = "{}/profiles/signup?next={}/social/login/chahub".format(
settings.SOCIAL_AUTH_CHAHUB_BASE_URL,
Expand Down
7 changes: 7 additions & 0 deletions src/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,10 @@
# on default queue when number of submissions are < RERUN_SUBMISSION_LIMIT
# =============================================================================
RERUN_SUBMISSION_LIMIT = os.environ.get('RERUN_SUBMISSION_LIMIT', 30)


# =============================================================================
# Enable or disbale regular email sign-in an sign-up
# =============================================================================
ENABLE_SIGN_UP = os.environ.get('ENABLE_SIGN_UP', 'True').lower() == 'true'
ENABLE_SIGN_IN = os.environ.get('ENABLE_SIGN_IN', 'True').lower() == 'true'
4 changes: 3 additions & 1 deletion src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@
</div>
{% else %}
<a href="{% url 'accounts:login' %}" class="ui button style_button item">Login</a>
<a href="{% url 'accounts:signup' %}" class="ui button style_button item">Sign-up</a>
{% if ENABLE_SIGN_UP %}
<a href="{% url 'accounts:signup' %}" class="ui button style_button item">Sign-up</a>
{% endif %}
{% endif %}
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

{% block content %}
<div class="sixteen wide mobile six wide computer centered column">
{% if ENABLE_SIGN_IN %}
<h2 class="ui blue centered header">
Login
</h2>
Expand Down Expand Up @@ -52,11 +53,14 @@ <h2 class="ui blue centered header">
</div>
<button class="ui fluid blue submit button" type="submit">Log In</button>
<div class="ui divider"></div>
<p>New to us? <a href="{% url 'accounts:signup' %}">Sign Up</a></p>
{% if ENABLE_SIGN_UP %}
<p>Don't have an account? <a href="{% url 'accounts:signup' %}">Sign Up</a></p>
{% endif %}
<p><a href="{% url 'accounts:password_reset' %}">Forgot your password?</a></p>

<div class="ui error message"></div>
</form>
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
2 changes: 2 additions & 0 deletions src/utils/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ def common_settings(request):
'USER_JSON_DATA': json.dumps(user_json_data),
'RABBITMQ_MANAGEMENT_URL': f"http://{settings.DOMAIN_NAME}:{settings.RABBITMQ_MANAGEMENT_PORT}",
'FLOWER_URL': f"http://{settings.DOMAIN_NAME}:{settings.FLOWER_PUBLIC_PORT}",
'ENABLE_SIGN_UP': settings.ENABLE_SIGN_UP,
'ENABLE_SIGN_IN': settings.ENABLE_SIGN_IN,
}