Adds email reset

master
Laurent 6 years ago
parent 9525b61e8b
commit 70ca6aeab6
  1. BIN
      db.sqlite3
  2. BIN
      news/__pycache__/urls.cpython-37.pyc
  3. BIN
      news/__pycache__/views.cpython-37.pyc
  4. 4
      news/static/news/css/app.css
  5. 2
      news/templates/news/user/change-password.html
  6. 7
      news/templates/news/user/password_reset_complete.html
  7. 17
      news/templates/news/user/password_reset_confirm.html
  8. 9
      news/templates/news/user/password_reset_done.html
  9. 1
      news/templates/news/user/password_reset_email.html
  10. 15
      news/templates/news/user/password_reset_form.html
  11. 2
      news/templates/news/user/password_reset_html_email.html
  12. 2
      news/templates/news/user/signin.html
  13. 19
      news/urls.py
  14. 3
      news/views.py
  15. BIN
      pokercc/__pycache__/settings.cpython-37.pyc
  16. 1
      pokercc/settings.py

Binary file not shown.

@ -227,6 +227,10 @@ form textarea:active, form textarea:hover, form textarea:visited, form textarea:
border-radius: 5px;
} */
form label {
color: #fff;
}
input[type=password] {
padding:0px 5px;
border:2px solid #ccc;

@ -9,7 +9,7 @@
<form method="post">
{% csrf_token %}
{{ form }}
<button type="submit">Save changes</button>
<button class="primary_button" type="submit">Save changes</button>
</form>
{% endblock %}

@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<p>
Your password has been set. You may go ahead and <a href="{% url 'news:signin' %}">sign in</a> now.
</p>
{% endblock %}

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
{% if validlink %}
<h3>Change password</h3>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button class="primary_button" type="submit">Change password</button>
</form>
{% else %}
<p>
The password reset link was invalid, possibly because it has already been used.
Please request a new password reset.
</p>
{% endif %}
{% endblock %}

@ -0,0 +1,9 @@
<!-- templates/registration/password_reset_done.html -->
{% extends 'base.html' %}
{% block title %}Email Sent{% endblock %}
{% block content %}
<h1>Check your inbox.</h1>
<p>We've emailed you instructions for setting your password. You should receive the email shortly!</p>
{% endblock %}

@ -0,0 +1,15 @@
<!-- templates/registration/password_reset_form.html -->
{% extends 'base.html' %}
{% block title %}Forgot Your Password?{% endblock %}
{% block content %}
<h1>Forgot your password?</h1>
<p>Enter your email address below, and we'll email instructions for setting a new one.</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="primary_button" type="submit">Send me instructions!</button>
</form>
{% endblock %}

@ -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 %}

@ -28,6 +28,8 @@
</tr>
</table>
</form>
<a href="{% url 'news:password_reset' %}">Forgotten password?</a>
</div>
{% endblock %}

@ -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/<uidb64>/<token>', 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/<uidb64>/<token>', views.empty_view, name='password_reset_confirm'),
]

@ -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('')

@ -29,6 +29,7 @@ DEBUG = True
ALLOWED_HOSTS = []
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Application definition

Loading…
Cancel
Save