Skip to content

Commit

Permalink
added change password function
Browse files Browse the repository at this point in the history
  • Loading branch information
joisemp committed Apr 2, 2024
1 parent 6a7141a commit a86c797
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions core/templates/core/change-password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h2>Change Password</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
<a href="{% url 'landing-page' %}">Back</a>
1 change: 1 addition & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
urlpatterns = [
path('login/', views.LoginView.as_view(), name='login'),
path('logout/', views.LogoutView.as_view(), name='logout'),
path('change-password/', views.ChangePasswordView.as_view(), name='change-password'),
]
6 changes: 6 additions & 0 deletions core/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.urls import reverse_lazy
from . forms import CustomAuthenticationForm
from django.views import generic
from django.contrib.auth import views
Expand All @@ -21,3 +22,8 @@ def form_valid(self, form):

class LogoutView(views.LogoutView):
template_name = 'core/logout.html'


class ChangePasswordView(views.PasswordChangeView):
template_name = 'core/change-password.html'
success_url = reverse_lazy('landing-page')
5 changes: 4 additions & 1 deletion main/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True


LOGIN_URL = '/core/login'
3 changes: 2 additions & 1 deletion templates/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ <h1>Landing Page</h1>
{% if user.is_authenticated %}
<p>{{user.email}}</p>
<p>To logout <a href="{% url 'core:logout' %}">Click here</a></p>
<a href="{% url 'core:change-password' %}">Change password</a>
{% else %}
<p>Not logged in <a href="{% url 'core:login' %}">Login</a></p>
{% endif %}
{% endif %}

0 comments on commit a86c797

Please sign in to comment.