Commit ab5e1af9 authored by BERJON Matthieu's avatar BERJON Matthieu

Add of a signup page

I added a simple signup page. It still needs some work on it such as the
place of the password policy and a reset password link.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent 1b232622
......@@ -12,4 +12,5 @@ urlpatterns = [
{'template_name': 'login.html'},
name='login'),
url(r'^logout/$', auth_views.logout, name='logout'),
url('^signup/$', views.SignUp.as_view(), name='signup'),
]
from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views import generic
from django.contrib.auth.models import User
from .models import Webapp
......@@ -19,9 +22,17 @@ def list_webapps(request):
return render(request, "webapps.html", locals())
def login(request):
pass
def signup(request):
pass
# def signup(request):
# if request.method == 'POST':
# form = UserCreationForm(request.POST)
# if form.is_valid():
# form.save()
# return redirect('poc_home')
# else:
# form = UserCreationForm()
#
# return render(request, 'signup.html', {'form': form})
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'signup.html'
......@@ -17,6 +17,9 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}"><i class="fas fa-sign-in-alt"></i> Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'signup' %}"><i class="fas fa-user-plus"></i> Sign up</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}"><i class="fas fa-sign-out-alt"></i> Sign out</a>
......
{% extends 'base.html' %}
{% block title %}Sign up{% endblock %}
{% block content %}
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
<div class="form-group">
<div class="row">
<div class="col">
{% for field in form %}
<p>{{ field.label_tag }} {{ field }}</p>
{% for error in field.errors %}
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ error }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endfor %}
</div>
<div class="col">
{% for field in form %}
{% if field.help_text %}
{{ field.help_text|safe }}
{% endif %}
{% endfor %}
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Sign up</button>
</form>
{% endblock %}
Markdown is supported
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