Login is possible

This commit is contained in:
Yohann D'ANELLO 2020-04-29 07:55:06 +02:00
parent 264f2b7e6b
commit 93735da1a4
14 changed files with 168 additions and 9 deletions

View File

@ -4,7 +4,7 @@ chardet==3.0.4
defusedxml==0.6.0 defusedxml==0.6.0
Django~=3.0 Django~=3.0
django-allauth==0.39.1 django-allauth==0.39.1
django-crispy-forms==1.7.2 django-crispy-forms==1.9.0
django-extensions==2.1.9 django-extensions==2.1.9
django-filter==2.2.0 django-filter==2.2.0
django-polymorphic==2.1.2 django-polymorphic==2.1.2
@ -19,7 +19,7 @@ requests==2.22.0
requests-oauthlib==1.2.0 requests-oauthlib==1.2.0
six==1.12.0 six==1.12.0
sqlparse==0.3.0 sqlparse==0.3.0
djangorestframework==3.9.0 djangorestframework==3.11.0
django-rest-polymorphic==0.1.8 django-rest-polymorphic==0.1.8
urllib3==1.25.3 urllib3==1.25.3
psycopg2-binary==2.8.4 psycopg2-binary==2.8.4

View File

@ -152,25 +152,20 @@
<ul class="navbar-nav"> <ul class="navbar-nav">
{% if not user.is_authenticated %} {% if not user.is_authenticated %}
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="/connexion"><i class="fas fa-sign-in-alt"></i> Connexion</a> <a class="nav-link" href="{% url "login" %}"><i class="fas fa-sign-in-alt"></i> Connexion</a>
</li> </li>
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="/inscription"><i class="fas fa-user-plus"></i> Inscription</a> <a class="nav-link" href="/inscription"><i class="fas fa-user-plus"></i> Inscription</a>
</li> </li>
{% else %} {% else %}
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="/deconnexion"><i class="fas fa-sign-out-alt"></i> Déconnexion</a> <a class="nav-link" href="{% url "logout" %}"><i class="fas fa-sign-out-alt"></i> Déconnexion</a>
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="container-fluid my-3" style="max-width: 1600px;"> <div class="container-fluid my-3" style="max-width: 1600px;">
{% if user.is_authenticated and not user.profile.email_confirmed %}
<div class="alert alert-warning">
{% trans "Your e-mail address is not validated. Please check your mail inbox and click on the validation link." %}
</div>
{% endif %}
{% block contenttitle %}<h1>{{ title }}</h1>{% endblock %} {% block contenttitle %}<h1>{{ title }}</h1>{% endblock %}
<div id="messages"></div> <div id="messages"></div>
{% block content %} {% block content %}

View File

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
{% if validlink %}
{% trans "Your email have successfully been validated." %}
{% if user_object.profile.registration_valid %}
{% blocktrans %}You can now <a href="{{ login_url }}">log in</a>.{% endblocktrans %}
{% else %}
{% trans "You must pay now your membership in the Kfet to complete your registration." %}
{% endif %}
{% else %}
{% trans "The link was invalid. The token may have expired. Please send us an email to activate your account." %}
{% endif %}
{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block content %}
<h2>Account Activation</h2>
An email has been sent. Please click on the link to activate your account.
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block content %}
<p>{% trans "Thanks for spending some quality time with the Web site today." %}</p>
<p><a href="{% url 'index' %}">{% trans 'Log in again' %}</a></p>
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-2.0-or-later
{% endcomment %}
{% load i18n crispy_forms_filters %}
{% block title %}{% trans "Log in" %}{% endblock %}
{% block contenttitle %}<h1>{% trans "Log in" %}</h1>{% endblock %}
{% block content %}
{% if user.is_authenticated %}
<p class="errornote">
{% blocktrans trimmed %}
You are authenticated as {{ user }}, but are not authorized to
access this page. Would you like to login to a different account?
{% endblocktrans %}
</p>
{% endif %}
<form method="post" id="login-form">
{% csrf_token %}
{{ form | crispy }}
<input type="submit" value="{% trans 'Log in' %}" class="btn btn-primary">
<a href="{% url 'password_reset' %}" class="badge badge-light">{% trans 'Forgotten your password or username?' %}</a>
</form>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block content %}
<p>{% trans 'Your password was changed.' %}</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}
{% block content %}
<form method="post">{% csrf_token %}
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
{{ form | crispy }}
<input class="btn btn-primary" type="submit" value="{% trans 'Change my password' %}">
</form>
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block content %}
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
<p>
<a href="{{ login_url }}" class="btn btn-success">{% trans 'Log in' %}</a>
</p>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}
{% block content %}
{% if validlink %}
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
<form method="post">{% csrf_token %}
{{ form | crispy }}
<input class="btn btn-primary" type="submit" value="{% trans 'Change my password' %}">
</form>
{% else %}
<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block content %}
<p>{% trans "We've emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly." %}</p>
<p>{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}
{% block content %}
<p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
<form method="post">{% csrf_token %}
{{ form | crispy }}
<input class="btn btn-primary" type="submit" value="{% trans 'Reset my password' %}">
</form>
{% endblock %}

View File

@ -0,0 +1,22 @@
<!-- templates/signup.html -->
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load i18n %}
{% block title %}{% trans "Sign up" %}{% endblock %}
{% block content %}
<h2>{% trans "Sign up" %}</h2>
<div class="alert alert-warning">
{% blocktrans %}If you already signed up, your registration is taken into account. The BDE must validate your account before your can log in. You have to go to the Kfet and pay the registration fee. You must also validate your email address by following the link you received.{% endblocktrans %}
</div>
<form method="post">
{% csrf_token %}
{{ form|crispy }}
{{ profile_form|crispy }}
<button class="btn btn-success" type="submit">
{% trans "Sign up" %}
</button>
</form>
{% endblock %}

View File

@ -43,6 +43,13 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.forms',
'polymorphic',
'crispy_forms',
'django_tables2',
'rest_framework',
'rest_framework.authtoken',
'member', 'member',
'tournament', 'tournament',
@ -152,3 +159,7 @@ STATICFILES_DIRS = [
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_ROOT = os.path.join(BASE_DIR, "media")
CRISPY_TEMPLATE_PACK = 'bootstrap4'
DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap4.html'