From 70ca6aeab6f147dd5ff5b199f62fa628480b6eed Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 30 Sep 2019 15:52:22 +0200 Subject: [PATCH] Adds email reset --- db.sqlite3 | Bin 196608 -> 196608 bytes news/__pycache__/urls.cpython-37.pyc | Bin 865 -> 1694 bytes news/__pycache__/views.cpython-37.pyc | Bin 5470 -> 5581 bytes news/static/news/css/app.css | 4 ++++ ...nge_password.html => change-password.html} | 2 +- .../news/user/password_reset_complete.html | 7 +++++++ .../news/user/password_reset_confirm.html | 17 ++++++++++++++++ .../news/user/password_reset_done.html | 9 +++++++++ .../news/user/password_reset_email.html | 1 + .../news/user/password_reset_form.html | 15 ++++++++++++++ .../news/user/password_reset_html_email.html | 2 ++ news/templates/news/user/signin.html | 2 ++ news/urls.py | 19 +++++++++++++++++- news/views.py | 3 +++ pokercc/__pycache__/settings.cpython-37.pyc | Bin 2338 -> 2407 bytes pokercc/settings.py | 1 + 16 files changed, 80 insertions(+), 2 deletions(-) rename news/templates/news/user/{change_password.html => change-password.html} (72%) create mode 100644 news/templates/news/user/password_reset_complete.html create mode 100644 news/templates/news/user/password_reset_confirm.html create mode 100644 news/templates/news/user/password_reset_done.html create mode 100644 news/templates/news/user/password_reset_email.html create mode 100644 news/templates/news/user/password_reset_form.html create mode 100644 news/templates/news/user/password_reset_html_email.html diff --git a/db.sqlite3 b/db.sqlite3 index a5631b5f5c83796158abf4e851b3f53124bbab0b..9c5c1e01a10119a8746a64298846ebd427ee3eb5 100644 GIT binary patch delta 637 zcmaixy-yQi9LIZ4DXmH4ucC=*G_f?s4S1gC?s{AkOlpsUk-K`iqvb9PkiKwz`f8}X z_8h3fgo6-=jxf0zLqgTT#1R(RbTa${COYe24Vw$|=lhm?`~7ggAKtsgo$TLEb0_cC zuFZ_cZwCB4_xf}A`qA#pkEW3m9p|x8UZh54<*v0ZB=jaN=#6$Nk!BTQ)~ZsuVMvBy zwpzHBaTBwdDs$agVUA)VPhokA$1y^ad?HDuY0L{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%VNZh0gt>=q3D>NzWu|30J1a?O*te6ZDrBtaBcPEWQv$vOO6p3~*>Ce}%n z24pE&*rLx#lE(ojzT9RpQiJ?W<^0ohpIN%B2t&e{U(nbaY_6sp)%;e(FDzarq}H`C z=^Q)JyBV*mBOS_VmHlZE!TGbNXYMJ_ek18w`Dkk`!Yq9s)pecSE=09&uBwEkV$wqy zcv>f}1M3;eajn-aphlL*Uxg$rz`Y>72w)WQU4LxPPU zM%soca2lO2gMzPVQzqGwqH0Y>+tRfiKGUBbk7Ne;>O)2owAqsQ>@~ delta 423 zcmXxgyH3L}6b4{B_a;rRNr6C_SRx_B!o-4j03^gjBveH@QK2Luate$U574PQD=_mm z8ITZD7oLINU@ZCQ|LkK~_Ot(KElz#kWf+&=Pgk!xV_y>gqmOWcS%07qBc8K@C%n)S zjWg0n&-KDc3}hoQGfrk^%q+6VUh0qo+0;^UA%{GrHq;`Y7JscB(50^0>_Hy&l?G6o z21-N7r=d~+btq5@p)Q3=BdA9kN}Euhwtl5i1Py4L?8Bu#^^+m(T(Ee&#w%H@HAa=r zuNzxr6B*WAuJXowxXB*t_ZNQ7kIv$t@o1Ko)4PLvk=H^)kHGgaVasBoG)`JolQJzb q;m9?2m7Du}fsCOnBiZBOG%lHEqO9MTh~!4JimhXF7qPdxwZ=dAv|p3} diff --git a/news/__pycache__/views.cpython-37.pyc b/news/__pycache__/views.cpython-37.pyc index e3f10c5d3667bd1d53c7ae86daf643c145bfcf81..5731023a0ac8c48c2af188e439797cd6ccd380fa 100644 GIT binary patch delta 150 zcmcbobyl0#iIVN=5GXb$P5EpX*i4uks#%4yKN+!Qs44RBZtdl>mNy%}g<`$Gx#+PNLmahP*1ZiPl lEXoIxnijVvy9j?^yfxWW {% csrf_token %} {{ form }} - + {% endblock %} diff --git a/news/templates/news/user/password_reset_complete.html b/news/templates/news/user/password_reset_complete.html new file mode 100644 index 0000000..4415e0d --- /dev/null +++ b/news/templates/news/user/password_reset_complete.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block content %} +

+ Your password has been set. You may go ahead and sign in now. +

+{% endblock %} diff --git a/news/templates/news/user/password_reset_confirm.html b/news/templates/news/user/password_reset_confirm.html new file mode 100644 index 0000000..fa5e045 --- /dev/null +++ b/news/templates/news/user/password_reset_confirm.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block content %} + {% if validlink %} +

Change password

+
+ {% csrf_token %} + {{ form.as_p }} + +
+ {% else %} +

+ The password reset link was invalid, possibly because it has already been used. + Please request a new password reset. +

+ {% endif %} +{% endblock %} diff --git a/news/templates/news/user/password_reset_done.html b/news/templates/news/user/password_reset_done.html new file mode 100644 index 0000000..3a72b85 --- /dev/null +++ b/news/templates/news/user/password_reset_done.html @@ -0,0 +1,9 @@ + +{% extends 'base.html' %} + +{% block title %}Email Sent{% endblock %} + +{% block content %} +

Check your inbox.

+

We've emailed you instructions for setting your password. You should receive the email shortly!

+{% endblock %} diff --git a/news/templates/news/user/password_reset_email.html b/news/templates/news/user/password_reset_email.html new file mode 100644 index 0000000..d64f5aa --- /dev/null +++ b/news/templates/news/user/password_reset_email.html @@ -0,0 +1 @@ +pouet pouet diff --git a/news/templates/news/user/password_reset_form.html b/news/templates/news/user/password_reset_form.html new file mode 100644 index 0000000..03a9232 --- /dev/null +++ b/news/templates/news/user/password_reset_form.html @@ -0,0 +1,15 @@ + +{% extends 'base.html' %} + +{% block title %}Forgot Your Password?{% endblock %} + +{% block content %} +

Forgot your password?

+

Enter your email address below, and we'll email instructions for setting a new one.

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/news/templates/news/user/password_reset_html_email.html b/news/templates/news/user/password_reset_html_email.html new file mode 100644 index 0000000..d159c9c --- /dev/null +++ b/news/templates/news/user/password_reset_html_email.html @@ -0,0 +1,2 @@ +Someone asked for password reset for email {{ email }}. Follow the link below: +{{ protocol}}://{{ domain }}{% url 'news:password_reset_confirm' uidb64=uid token=token %} diff --git a/news/templates/news/user/signin.html b/news/templates/news/user/signin.html index fe4da3f..0136853 100644 --- a/news/templates/news/user/signin.html +++ b/news/templates/news/user/signin.html @@ -28,6 +28,8 @@ + + Forgotten password? {% endblock %} diff --git a/news/urls.py b/news/urls.py index 9659c7f..013eafa 100644 --- a/news/urls.py +++ b/news/urls.py @@ -1,4 +1,5 @@ -from django.urls import path, re_path +from django.urls import path, re_path, include +from django.contrib.auth import views as auth_views from . import views @@ -17,5 +18,21 @@ urlpatterns = [ path('logout', views.logout_view, name='logout_view'), path('password-change', views.password_change, name='password_change'), re_path(r'^register/$', views.register, name='register'), + # path('change-password/', auth_views.PasswordChangeView.as_view(template_name='change-password.html'),), + # path('change-password/done', views.password_change, name='password_change_done'), + # path('password-reset', auth_views.PasswordResetView.as_view(template_name='news/user/password_reset_form.html'), name='password_reset'), + path('password_reset/', auth_views.PasswordResetView.as_view( + template_name='news/user/password_reset_form.html', + email_template_name='news/user/password_reset_email.html', + html_email_template_name='news/user/password_reset_html_email.html', + success_url='../password-reset/done' + ), name='password_reset'), + path('password-reset/done', auth_views.PasswordResetDoneView.as_view(template_name='news/user/password_reset_done.html'), name='password_reset_done'), + # path('accounts/', include('django.contrib.auth.urls')), + path('reset//', auth_views.PasswordResetConfirmView.as_view( + template_name='news/user/password_reset_confirm.html', + success_url='../password-change/done'), name='password_reset_confirm'), + path('password-change/done', auth_views.PasswordResetCompleteView.as_view(template_name='news/user/password_reset_complete.html'), name='password_change_done'), + # path('reset//', views.empty_view, name='password_reset_confirm'), ] diff --git a/news/views.py b/news/views.py index 4701cb1..31e0bcc 100644 --- a/news/views.py +++ b/news/views.py @@ -164,3 +164,6 @@ def upvote(request, comment_id): comment.save() post = comment.post return HttpResponseRedirect(reverse('news:post', args=(post.id,))) + +def empty_view(request): + return HttpResponse('') diff --git a/pokercc/__pycache__/settings.cpython-37.pyc b/pokercc/__pycache__/settings.cpython-37.pyc index 6e75b4bd6acc24a72a532457f37f92be40274aaa..d8c19648747543e38680e1ffdb06c284d1ff4e35 100644 GIT binary patch delta 305 zcmXAly-vbV9L0Mt*S1z~fdYl{;RmRQCiNMpHqoHQ#JJqV800if5orRGlZ%rZ>B^wK zf#C&oaq|TnU3?9%_&+%(C%^os^J4v2+~eF(Wf`=U#B=ScHKkEQ7-g zHDMx+46?A0LmmZ5(y&Da#ZZBY5*(CKK{aF%L2b%HBC=Q!7FMwqkUo9V0~PDf6!j^M zh{&OV4f)x?<~+CN*^EfYL>{$mQ9w)BP(@L?B<)~FltIsx*6z$8k7Un9zdHWnkbG*dYF$n+ bswWS+XA4;w)l*fYo){bmTp+12LFF=R2 z4`AzC5N?>{n@lEC%zyk9+l95&!0Y$$^0->tl>XM!yA=#7sNxLgu&yi?A!?{2LW~9y z--KvN4J{Wyqm2$ybaCN0C-gS#Nb0zh2v_JY=}CQA={{&B*qZeemTVGs2x+ccq_jak@?n{|Nop7d$UL$d}L)x PJ;fAiF0o==^eeYVB1Se| diff --git a/pokercc/settings.py b/pokercc/settings.py index 4ec7910..393b003 100644 --- a/pokercc/settings.py +++ b/pokercc/settings.py @@ -29,6 +29,7 @@ DEBUG = True ALLOWED_HOSTS = [] +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Application definition