Commit 4e2e61d1 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

add an intermediate 'user_need_validation' page for email validation

There are multiple reasons:
- we can use the same page for validating the 'Terms of Use'
- the user may already have received the message
- we should do the same validation on the API too (but API should not
  send any email but just display the error message)
parent 3778463e
......@@ -47,11 +47,7 @@ class AllgoValidAccountMixin:
if not any(addr.verified for addr in email_addresses):
# user has no verified address
# TODO: do not send the emails immediately but display a page
# with a link to send the email
for addr in email_addresses:
return redirect("account_email_verification_sent")
return redirect("main:user_need_validation")
return super().dispatch(request, *args, **kwargs)
......@@ -74,6 +74,7 @@ urlpatterns = [
url(r'^profile/ssh/add$', views.UserSSHAdd.as_view(), name='user_ssh_add'),
url(r'^profile/ssh/delete$', views.UserSSHDelete.as_view(), name='user_ssh_delete'),
url(r'^profile/password$', views.UserPasswordUpdate.as_view(), name='user_password'),
url(r'^profile/need_validation$', views.UserNeedValidation.as_view(), name='user_need_validation'),
# url(r'^runners/$', views.RunnerList.as_view(), name='runner_list'),
# url(r'^runners/_add$', views.RunnerCreate.as_view(), name='runner_create'),
......@@ -417,8 +417,10 @@ class WebappImport(ProviderAccessMixin, SuccessMessageMixin, FormView):
# ensure the user email is verified
if not email_addr.verified:
return redirect("account_email_verification_sent")
"Webapp %r belongs to %r but this address is still not verified"
% (docker_name,
return redirect("main:user_need_validation")
# We can import the webapp !
......@@ -919,6 +921,40 @@ class UserPasswordUpdate(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
return super(UserPasswordUpdate, self) \
.dispatch(request, *args, **kwargs)
class UserNeedValidation(LoginRequiredMixin, DetailView):
"""This page is displayed when the user has not completed the registration process
- email address needs verification
template_name = "user_need_validation.html"
def get_object(self):
return None
def get(self, request):
if all(addr.verified for addr in request.user.email_addresses):
# redirect to the main page if validation is complete
messages.success(request, "Your account is fully validated")
return redirect("main:home")
return super().get(request)
def post(self, request):
# re-send a confirmation e-mail if 'confirm_address_id' is provided
email_addr = request.user.email_addresses.get(
except (KeyError, ValueError, ObjectDoesNotExist):
if not email_addr.verified:
"Confirmation e-mail sent to %s" %
return redirect(request.path_info)
# -----------------------------------------------------------------------------
{% extends "base.html" %}
{% load static htmlattrs socialaccount %}
{% block title %}Account needs validation{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item active" aria-current="page">My profile</li>
{% endblock %}
{% block content %}
<div class="container">
<div class="allgo-page">
<div class="pb-3 mb-3">
<h2>Your account needs validation</h2>
<h5>Email address</h5>
<table class="table">
{% for addr in user.email_addresses %}
{% if addr.verified %}
<td><i class="text-success">Verified</i></td>
{% else %}
<i class="text-danger">Unverified</i>
<form class="form-inline mt-0" method="post">
{% csrf_token %}
<input type="hidden" name="confirm_address_id" value="{{}}"/>
<input class="btn btn-primary" type="submit" value="Re-send verification e-mail"/>
{% endif %}
{% endfor %}
{% endblock %}
{% block messages %}
{{ block.super }}
{% include 'partials/_form_messages.html' %}
{% endblock %}
{% block javascript %}
{{ block.super }}
<script defer src="{% static 'js/tooltip.js' %}"></script>
<script defer src="{% static 'js/copy.js' %}"></script>
{% endblock %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment