diff --git a/Projet/ChandelIIEr/__pycache__/__init__.cpython-35.pyc b/Projet/ChandelIIEr/__pycache__/__init__.cpython-35.pyc index 54fb1c3de038b2712b5d4eb77e7ce2d64f198dac..9a1d86571131aa3296dc99d4a4e8e15e2ea6b5d2 100644 Binary files a/Projet/ChandelIIEr/__pycache__/__init__.cpython-35.pyc and b/Projet/ChandelIIEr/__pycache__/__init__.cpython-35.pyc differ diff --git a/Projet/ChandelIIEr/__pycache__/settings.cpython-35.pyc b/Projet/ChandelIIEr/__pycache__/settings.cpython-35.pyc index 27d58475b32e561728b609b09fc540bdb88cee52..d64aa55e566b7565570f752f1d0bc02b87c95c66 100644 Binary files a/Projet/ChandelIIEr/__pycache__/settings.cpython-35.pyc and b/Projet/ChandelIIEr/__pycache__/settings.cpython-35.pyc differ diff --git a/Projet/ChandelIIEr/__pycache__/urls.cpython-35.pyc b/Projet/ChandelIIEr/__pycache__/urls.cpython-35.pyc index 40e4484b4621d709f9ba3eca3ddf780bd1f25731..fbdda2dcc73d3769db05a16b2669450c24d9e920 100644 Binary files a/Projet/ChandelIIEr/__pycache__/urls.cpython-35.pyc and b/Projet/ChandelIIEr/__pycache__/urls.cpython-35.pyc differ diff --git a/Projet/ChandelIIEr/__pycache__/wsgi.cpython-35.pyc b/Projet/ChandelIIEr/__pycache__/wsgi.cpython-35.pyc index 926ab7106017f86c7d3640b44a72d5ff19341f3c..71ee8ccf185b3cd94ee231d5d8503e1e951eaf02 100644 Binary files a/Projet/ChandelIIEr/__pycache__/wsgi.cpython-35.pyc and b/Projet/ChandelIIEr/__pycache__/wsgi.cpython-35.pyc differ diff --git a/Projet/db.sqlite3 b/Projet/db.sqlite3 index c33f2f5f4e98550092e4c6f1fe111dc3a916f94a..5a8f6600885399a4ec9924154507dfcebce1e621 100644 Binary files a/Projet/db.sqlite3 and b/Projet/db.sqlite3 differ diff --git a/Projet/polls/__pycache__/__init__.cpython-35.pyc b/Projet/polls/__pycache__/__init__.cpython-35.pyc index 7fc2b92f6dbc34c31ebc253f26ae00f0dc91cc7f..19e8f865e34f4ace801a305210972b92f763381e 100644 Binary files a/Projet/polls/__pycache__/__init__.cpython-35.pyc and b/Projet/polls/__pycache__/__init__.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/admin.cpython-35.pyc b/Projet/polls/__pycache__/admin.cpython-35.pyc index 411c08fe7870a8971c3ba3845bab2e7466254b35..1c222697a252ec7b0b23f3cd28db618c7f165663 100644 Binary files a/Projet/polls/__pycache__/admin.cpython-35.pyc and b/Projet/polls/__pycache__/admin.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/apps.cpython-35.pyc b/Projet/polls/__pycache__/apps.cpython-35.pyc index 12024cec0ddbe96bebcc5c6011b32acd8ad4ff0b..fbc5ca641b5b73ef676a4e34584adf230bb76f9b 100644 Binary files a/Projet/polls/__pycache__/apps.cpython-35.pyc and b/Projet/polls/__pycache__/apps.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/forms.cpython-35.pyc b/Projet/polls/__pycache__/forms.cpython-35.pyc index 65d4b7f2d0b4394815cead2f2ea0c5ad7786dc43..1ff7aa6b41a6cadb6b8a97c73eee0676316b51ce 100644 Binary files a/Projet/polls/__pycache__/forms.cpython-35.pyc and b/Projet/polls/__pycache__/forms.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/models.cpython-35.pyc b/Projet/polls/__pycache__/models.cpython-35.pyc index e1149c93c90c864a8bc9d4c13fa5b847067f64c2..367b7cf8c82b8e70040f79e41b57de8f0770792d 100644 Binary files a/Projet/polls/__pycache__/models.cpython-35.pyc and b/Projet/polls/__pycache__/models.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/urls.cpython-35.pyc b/Projet/polls/__pycache__/urls.cpython-35.pyc index dfdc90427abe6ffb2d3d849494bbbf9eda0da9b6..ec50b3b08cd9b5fc4231125056ae3ac151acec9a 100644 Binary files a/Projet/polls/__pycache__/urls.cpython-35.pyc and b/Projet/polls/__pycache__/urls.cpython-35.pyc differ diff --git a/Projet/polls/__pycache__/views.cpython-35.pyc b/Projet/polls/__pycache__/views.cpython-35.pyc index c8aa3094274342976cb849659ac4bc653f439f55..0268405a220cdd0e5da4fcfa1f8f81a967241633 100644 Binary files a/Projet/polls/__pycache__/views.cpython-35.pyc and b/Projet/polls/__pycache__/views.cpython-35.pyc differ diff --git a/Projet/polls/forms.py b/Projet/polls/forms.py index d0894ccd4a1845b109acf1899e4b8bfae6c33965..9354fe6aa137d2bc8dfa5439414f1e913e3aa5f6 100644 --- a/Projet/polls/forms.py +++ b/Projet/polls/forms.py @@ -36,3 +36,7 @@ class InscriptionForm(forms.Form): class ConnexionForm(forms.Form): username = forms.CharField(max_length=50) passwd = forms.CharField(widget=forms.PasswordInput) + +class ForgottenPasswdForm(forms.Form): + mail = forms.EmailField() + new = forms.CharField(widget=forms.PasswordInput) \ No newline at end of file diff --git a/Projet/polls/migrations/__pycache__/__init__.cpython-35.pyc b/Projet/polls/migrations/__pycache__/__init__.cpython-35.pyc index af96c94827c6a3b4155d0042740fef20f6bb340b..42033b1523376a5fb5518db42917b553c3330f6c 100644 Binary files a/Projet/polls/migrations/__pycache__/__init__.cpython-35.pyc and b/Projet/polls/migrations/__pycache__/__init__.cpython-35.pyc differ diff --git a/Projet/polls/templates/polls/connexion.html b/Projet/polls/templates/polls/connexion.html index 9b3f3df826881afaca68410b6b0796d1d6386e96..920dfdc717061e6911938f46ec0b6279d4f6babd 100644 --- a/Projet/polls/templates/polls/connexion.html +++ b/Projet/polls/templates/polls/connexion.html @@ -39,7 +39,10 @@ Vous êtes connecté, {{ user.username }} ! </form> -<input class="button_submit"type="submit" value="Mot de passe oublié ?"/> +<form method="post" action="/polls/forgotten_passwd"> + {% csrf_token %} + <input class="button_submit"type="submit" value="Mot de passe oublié ?"/> +</form> {% endif %} diff --git a/Projet/polls/templates/polls/forgotten_passwd.html b/Projet/polls/templates/polls/forgotten_passwd.html new file mode 100644 index 0000000000000000000000000000000000000000..ed25b72ec7d398d2936669d8461cb27d8aaaa37b --- /dev/null +++ b/Projet/polls/templates/polls/forgotten_passwd.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +{% load static %} +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Mot de passe oublié</title> +</head> + +<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" /> + +<body> + +{% if user.is_authenticated %} + +Vous êtes connecté, {{ user.username }} ! + +{% else %} + +<form method="post" action="/polls/manage_forgotten_passwd"> + + {% csrf_token %} + <h2 class="inscription-title-block">Mot de passe oublié</h2> + <div class="inscription-block"> + <h3 class="inscription-data">Adresse mail liée au compte</h3> + {% if error %} + <p><strong>Adresse mail invalide</strong></p> + {% endif %} + <div class="inscription-form"> + <br/> + {{ form.mail }} + </div> + <h3 class="inscription-data">Choisissez un nouveau mot de passe</h3> + <div class="inscription-form"> + <br/> + {{ form.new }} + </div> + </div> + <input class="button_submit" type="submit" value="Envoyez-moi un mail de confirmation" /> + +</form> + +{% endif %} + +</body> +</html> \ No newline at end of file diff --git a/Projet/polls/urls.py b/Projet/polls/urls.py index 1343c5ea956f18362247ec7615ada0397646cdeb..78aaba6a1251143040d4847356a706fe0900d627 100644 --- a/Projet/polls/urls.py +++ b/Projet/polls/urls.py @@ -13,6 +13,8 @@ urlpatterns = [ url(r'^connexion$', views.connexion, name='connexion'), url(r'^manage_connexion$', views.manage_connexion, name='manage_connexion'), url(r'^deconnexion$', views.deconnexion, name='deconnexion'), + url(r'^forgotten_passwd$', views.forgotten_passwd, name='forgotten_passwd'), + url(r'^manage_forgotten_passwd$', views.manage_forgotten_passwd, name='manage_forgotten_passwd'), url(r'^(?P<urlrapport>[0-9A-Za-z]+)/$',views.rapport,name='rapport'), # ex: /polls/5/ # url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'), diff --git a/Projet/polls/views.py b/Projet/polls/views.py index b11af0ceca02058d7d56461473c8651cd060e75d..21cf4238bff6f9c2347acc0b4e42bce136057363 100644 --- a/Projet/polls/views.py +++ b/Projet/polls/views.py @@ -176,6 +176,34 @@ def deconnexion(request): logout(request) return redirect(reverse(connexion)) +def forgotten_passwd(request): + template = loader.get_template('polls/forgotten_passwd.html') + form = ForgottenPasswdForm(request.POST) + context = { + 'form': form, + } + return HttpResponse(template.render(context, request)) + +def manage_forgotten_passwd(request): + error = False + form = ForgottenPasswdForm(request.POST) + if form.is_valid(): + mail = form.cleaned_data['mail'] + new = form.cleaned_data['new'] + user = User.objects.get(email=mail) + if user: + user.set_password(new) + user.save() + return HttpResponse("Votre nouveau mot de passe a bien été pris en compte") + else: + error = True + template = loader.get_template('polls/forgotten_passwd.html') + context = { + 'error': error, + 'form': form, + } + return HttpResponse(template.render(context, request)) + def prof(request): latest_rapport_list = Rapport.objects.order_by('url')[:5] template = loader.get_template('polls/prof.html')