From 8427da2f08ae590b427027abe36351018c685f8e Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 1 Feb 2017 13:00:34 +0530 Subject: Forgot Password and Reset Issue Resolved The problem was: We have included yaksh urls to the project urls with the namespace "yaksh". So whenever we call the url name i.e "yaksh:" a reverse match is made. But for Forgot Password and Change Password we are using django's in-built functionality, where the reverse url is hardcoded. So the reverse match fails as the namespace is not specified! To resolve this, created a urls_password_reset URL dispatcher file and included to the project urls. --- online_test/urls.py | 1 + yaksh/templates/register/password_change_done.html | 15 ------------- yaksh/templates/register/password_change_form.html | 16 ------------- .../register/password_reset_complete.html | 6 ----- .../templates/register/password_reset_confirm.html | 15 ------------- yaksh/templates/register/password_reset_done.html | 3 --- yaksh/templates/register/password_reset_form.html | 10 --------- .../registration/password_change_done.html | 15 +++++++++++++ .../registration/password_change_form.html | 16 +++++++++++++ .../registration/password_reset_complete.html | 6 +++++ .../registration/password_reset_confirm.html | 15 +++++++++++++ .../registration/password_reset_done.html | 3 +++ .../registration/password_reset_form.html | 10 +++++++++ yaksh/templates/user.html | 2 +- yaksh/templates/yaksh/login.html | 2 +- yaksh/urls.py | 26 ---------------------- yaksh/urls_password_reset.py | 20 +++++++++++++++++ 17 files changed, 88 insertions(+), 93 deletions(-) delete mode 100644 yaksh/templates/register/password_change_done.html delete mode 100644 yaksh/templates/register/password_change_form.html delete mode 100644 yaksh/templates/register/password_reset_complete.html delete mode 100644 yaksh/templates/register/password_reset_confirm.html delete mode 100644 yaksh/templates/register/password_reset_done.html delete mode 100644 yaksh/templates/register/password_reset_form.html create mode 100644 yaksh/templates/registration/password_change_done.html create mode 100644 yaksh/templates/registration/password_change_form.html create mode 100644 yaksh/templates/registration/password_reset_complete.html create mode 100644 yaksh/templates/registration/password_reset_confirm.html create mode 100644 yaksh/templates/registration/password_reset_done.html create mode 100644 yaksh/templates/registration/password_reset_form.html create mode 100644 yaksh/urls_password_reset.py diff --git a/online_test/urls.py b/online_test/urls.py index 8e733b9..ce0de41 100644 --- a/online_test/urls.py +++ b/online_test/urls.py @@ -11,6 +11,7 @@ urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^exam/', include('yaksh.urls', namespace='yaksh', app_name='yaksh')), + url(r'^exam/reset/', include('yaksh.urls_password_reset')), url(r'^', include('social.apps.django_app.urls', namespace='social')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/yaksh/templates/register/password_change_done.html b/yaksh/templates/register/password_change_done.html deleted file mode 100644 index 14df20c..0000000 --- a/yaksh/templates/register/password_change_done.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "base.html" %} - -{% block pagetitle %}Password change successful{% endblock %} -{% block script %} - -{% endblock %} -{% block content %} -

Your password has been changed successfully.

-

Redirecting ...

-{% endblock %} diff --git a/yaksh/templates/register/password_change_form.html b/yaksh/templates/register/password_change_form.html deleted file mode 100644 index b618410..0000000 --- a/yaksh/templates/register/password_change_form.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "base.html" %} - -{% block pagetitle %} Change Password {% endblock %} - -{% block content %} -
- {% csrf_token %} -
- - {{ form }} -
-
-
-
-
-{% endblock content %} diff --git a/yaksh/templates/register/password_reset_complete.html b/yaksh/templates/register/password_reset_complete.html deleted file mode 100644 index 0c1bae2..0000000 --- a/yaksh/templates/register/password_reset_complete.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "base.html" %} -{% block pagetitle %}Password reset complete{% endblock %} -{% block content %} -

Your password has been reset.

-

Log in

-{% endblock %} diff --git a/yaksh/templates/register/password_reset_confirm.html b/yaksh/templates/register/password_reset_confirm.html deleted file mode 100644 index 1b0a1b7..0000000 --- a/yaksh/templates/register/password_reset_confirm.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "base.html" %} -{% block pagetitle %}Reset Password{% endblock %} - -{% block content %} - {% if validlink %} -

Please enter your new password twice so we can verify you typed it in correctly

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

This reset link is no longer valid!

- {% endif %} -{% endblock %} diff --git a/yaksh/templates/register/password_reset_done.html b/yaksh/templates/register/password_reset_done.html deleted file mode 100644 index 1ac7b60..0000000 --- a/yaksh/templates/register/password_reset_done.html +++ /dev/null @@ -1,3 +0,0 @@ -{% extends "base.html" %} -{% block title %}Password reset successful{% endblock %} -{% block pagetitle %} Instruction for setting new password has been mailed to your registered email address {% endblock %} diff --git a/yaksh/templates/register/password_reset_form.html b/yaksh/templates/register/password_reset_form.html deleted file mode 100644 index 0444584..0000000 --- a/yaksh/templates/register/password_reset_form.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base.html" %} -{% block pagetitle %} Email will be send to the registered email address {% endblock %} -{% block content %} -
- {% csrf_token %} - {{ form }} - - Cancel -
-{% endblock content %} diff --git a/yaksh/templates/registration/password_change_done.html b/yaksh/templates/registration/password_change_done.html new file mode 100644 index 0000000..14df20c --- /dev/null +++ b/yaksh/templates/registration/password_change_done.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block pagetitle %}Password change successful{% endblock %} +{% block script %} + +{% endblock %} +{% block content %} +

Your password has been changed successfully.

+

Redirecting ...

+{% endblock %} diff --git a/yaksh/templates/registration/password_change_form.html b/yaksh/templates/registration/password_change_form.html new file mode 100644 index 0000000..b618410 --- /dev/null +++ b/yaksh/templates/registration/password_change_form.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block pagetitle %} Change Password {% endblock %} + +{% block content %} +
+ {% csrf_token %} +
+ + {{ form }} +
+
+
+
+
+{% endblock content %} diff --git a/yaksh/templates/registration/password_reset_complete.html b/yaksh/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..0c1bae2 --- /dev/null +++ b/yaksh/templates/registration/password_reset_complete.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} +{% block pagetitle %}Password reset complete{% endblock %} +{% block content %} +

Your password has been reset.

+

Log in

+{% endblock %} diff --git a/yaksh/templates/registration/password_reset_confirm.html b/yaksh/templates/registration/password_reset_confirm.html new file mode 100644 index 0000000..1b0a1b7 --- /dev/null +++ b/yaksh/templates/registration/password_reset_confirm.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block pagetitle %}Reset Password{% endblock %} + +{% block content %} + {% if validlink %} +

Please enter your new password twice so we can verify you typed it in correctly

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

This reset link is no longer valid!

+ {% endif %} +{% endblock %} diff --git a/yaksh/templates/registration/password_reset_done.html b/yaksh/templates/registration/password_reset_done.html new file mode 100644 index 0000000..1ac7b60 --- /dev/null +++ b/yaksh/templates/registration/password_reset_done.html @@ -0,0 +1,3 @@ +{% extends "base.html" %} +{% block title %}Password reset successful{% endblock %} +{% block pagetitle %} Instruction for setting new password has been mailed to your registered email address {% endblock %} diff --git a/yaksh/templates/registration/password_reset_form.html b/yaksh/templates/registration/password_reset_form.html new file mode 100644 index 0000000..0444584 --- /dev/null +++ b/yaksh/templates/registration/password_reset_form.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block pagetitle %} Email will be send to the registered email address {% endblock %} +{% block content %} +
+ {% csrf_token %} + {{ form }} + + Cancel +
+{% endblock content %} diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html index 6f2137d..6f879fe 100644 --- a/yaksh/templates/user.html +++ b/yaksh/templates/user.html @@ -29,7 +29,7 @@
  • Home
  • Enrolled Courses
  • Profile
  • -
  • Change Password
  • +
  • Change Password
  • diff --git a/yaksh/templates/yaksh/login.html b/yaksh/templates/yaksh/login.html index 0a6fdc1..e4b5933 100644 --- a/yaksh/templates/yaksh/login.html +++ b/yaksh/templates/yaksh/login.html @@ -12,7 +12,7 @@ {{ form.as_table }} - Forgot Password? + Forgot Password? New User? Sign-Up

    Login with

    diff --git a/yaksh/urls.py b/yaksh/urls.py index 629f8f5..5544088 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -1,33 +1,7 @@ from django.conf.urls import patterns, url from yaksh import views -from django.contrib.auth.views import password_reset, password_reset_confirm,\ - password_reset_done, password_reset_complete, password_change,\ - password_change_done -# app_name = 'yaksh' urlpatterns = [ - url(r'^forgotpassword/$', password_reset, - {'template_name': 'register/password_reset_form.html'}, - name="password_reset"), - url(r'^password_reset/(?P[0-9A-Za-z]+)-(?P.+)/$', - password_reset_confirm, - {'template_name': 'register/password_reset_confirm.html'}, - name='password_reset_confirm'), - url(r'^password_reset/mail_sent/$', password_reset_done, - {'template_name': 'register/password_reset_done.html'}, - name='password_reset_done'), - url(r'^password_reset/complete/$', password_reset_complete, - {'template_name': 'register/password_reset_complete.html'}, - name='password_reset_complete'), - url(r'^changepassword/$', password_change, - {'template_name': 'register/password_change_form.html'}, - name='password_change'), - url(r'^password_change/done/$', password_change_done, - {'template_name': 'register/password_change_done.html'}, - name='password_change_done'), -] - -urlpatterns += [ url(r'^$', views.index), url(r'^login/$', views.user_login, name='login'), url(r'^quizzes/$', views.quizlist_user, name='quizlist_user'), diff --git a/yaksh/urls_password_reset.py b/yaksh/urls_password_reset.py new file mode 100644 index 0000000..c1e36c6 --- /dev/null +++ b/yaksh/urls_password_reset.py @@ -0,0 +1,20 @@ +from django.conf.urls import patterns, url +from django.contrib.auth.views import password_reset, password_reset_confirm,\ + password_reset_done, password_reset_complete, password_change,\ + password_change_done + +urlpatterns = [ + url(r'^forgotpassword/$', password_reset, + name="password_reset"), + url(r'^password_reset/(?P[0-9A-Za-z]+)-(?P.+)/$', + password_reset_confirm, + name='password_reset_confirm'), + url(r'^password_reset/mail_sent/$', password_reset_done, + name='password_reset_done'), + url(r'^password_reset/complete/$', password_reset_complete, + name='password_reset_complete'), + url(r'^changepassword/$', password_change, + name='password_change'), + url(r'^password_change/done/$', password_change_done, + name='password_change_done'), +] -- cgit