Reset password page
This commit is contained in:
parent
553686e2ae
commit
b4a0a4da0c
16
templates/resetPassword.html
Normal file
16
templates/resetPassword.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{% extends "authBase.html" %}
|
||||||
|
|
||||||
|
{% block title %}Reset password{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Reset password</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="email" id="email" name="email" class="form-control" placeholder="Email" required><br><br>
|
||||||
|
<input type="submit" value="Send email"><br><br>
|
||||||
|
</form>
|
||||||
|
<div class="linkDefault">
|
||||||
|
<a href="{% url 'login' %}">Go back</a>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
17
templates/restePasswordConfirm.html
Normal file
17
templates/restePasswordConfirm.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{% extends "authBase.html" %}
|
||||||
|
|
||||||
|
{% block title %}Confirm reset password{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Create new password</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" id="uid" name="uid" class="form-control" placeholder="UID" required><br><br>
|
||||||
|
<input type="text" id="token" name="token" class="form-control" placeholder="TOken" required><br><br>
|
||||||
|
<input type="text" id="code" name="code" class="form-control" placeholder="Code" required><br><br>
|
||||||
|
<input type="password" id="newPassword" name="newPassword" class="form-control" placeholder="New password" required><br><br>
|
||||||
|
<input type="password" id="repeatNewPassword" name="repeatNewPassword" class="form-control" placeholder="Repeat password" required><br><br>
|
||||||
|
<input type="submit" value="Save new password"><br><br>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
@ -20,6 +20,8 @@ import requests
|
|||||||
|
|
||||||
|
|
||||||
def addTest(request):
|
def addTest(request):
|
||||||
|
if request.POST:
|
||||||
|
return redirect('home')
|
||||||
return render(request, 'createTest.html')
|
return render(request, 'createTest.html')
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ from django.urls import path
|
|||||||
from users.views import UserModelViewSet
|
from users.views import UserModelViewSet
|
||||||
from rest_framework_simplejwt.views import TokenObtainPairView
|
from rest_framework_simplejwt.views import TokenObtainPairView
|
||||||
from rest_framework_simplejwt.views import TokenRefreshView
|
from rest_framework_simplejwt.views import TokenRefreshView
|
||||||
from .views import PasswordReset, UserPasswordResetConfirmView, RegisterViewSet, login, logout, register, register_success, account, changeEmail, changeName, changePassword
|
from .views import PasswordReset, UserPasswordResetConfirmView, RegisterViewSet, login, logout, register, \
|
||||||
|
register_success, account, changeEmail, changeName, changePassword, resetPassword, resetPasswordConfirm
|
||||||
|
|
||||||
|
|
||||||
router = DefaultRouter(trailing_slash=False)
|
router = DefaultRouter(trailing_slash=False)
|
||||||
@ -16,13 +17,13 @@ urlpatterns = [
|
|||||||
path('login', login, name='login'),
|
path('login', login, name='login'),
|
||||||
path('logout', logout, name='logout'),
|
path('logout', logout, name='logout'),
|
||||||
path('register/success', register_success, name='register_success'),
|
path('register/success', register_success, name='register_success'),
|
||||||
#path('login/success', login_success, name='login_success'),
|
|
||||||
# path('register', RegisterViewSet.as_view(), name='register'),
|
|
||||||
path('register', register, name='register'),
|
path('register', register, name='register'),
|
||||||
path('api/token', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
path('api/token', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||||
path('api/token/refresh', TokenRefreshView.as_view(), name='token_refresh'),
|
path('api/token/refresh', TokenRefreshView.as_view(), name='token_refresh'),
|
||||||
path("password/reset", PasswordReset.as_view(), name="resetPassword"),
|
#path("password/reset", PasswordReset.as_view(), name="resetPassword"),
|
||||||
path("password/reset/confirm", UserPasswordResetConfirmView.as_view(), name="resetPasswordConfirm"),
|
#path("password/reset/confirm", UserPasswordResetConfirmView.as_view(), name="resetPasswordConfirm"),
|
||||||
|
path("password/reset", resetPassword, name="resetPassword"),
|
||||||
|
path("password/reset/confirm", resetPasswordConfirm, name="resetPasswordConfirm"),
|
||||||
path("email/change", changeEmail, name='changeEmail'),
|
path("email/change", changeEmail, name='changeEmail'),
|
||||||
path("name/change", changeName, name='changeName'),
|
path("name/change", changeName, name='changeName'),
|
||||||
path("password/change", changePassword, name='changePassword'),
|
path("password/change", changePassword, name='changePassword'),
|
||||||
|
@ -167,3 +167,46 @@ def changePassword(request):
|
|||||||
# u.save()
|
# u.save()
|
||||||
return redirect('account')
|
return redirect('account')
|
||||||
return render(request, 'changePassword.html')
|
return render(request, 'changePassword.html')
|
||||||
|
|
||||||
|
|
||||||
|
def resetPassword(request):
|
||||||
|
"""
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"email": "test@test.com",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
|
if request.POST:
|
||||||
|
email = request.POST.get("email")
|
||||||
|
serializer_class = UserPasswordResetSerializer
|
||||||
|
permission_classes = (permissions.AllowAny,)
|
||||||
|
return redirect('resetPasswordConfirm')
|
||||||
|
return render(request, 'resetPassword.html')
|
||||||
|
|
||||||
|
|
||||||
|
def resetPasswordConfirm(request):
|
||||||
|
"""
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"uid": "NYz",
|
||||||
|
"token": "asdasdasd",
|
||||||
|
"code": 123456,
|
||||||
|
"newPassword": "testowe",
|
||||||
|
"repeatNewPassword": "testowe"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
if request.POST:
|
||||||
|
uid = request.POST.get("uid")
|
||||||
|
token = request.POST.get("token")
|
||||||
|
code = request.POST.get("code")
|
||||||
|
newPassword = request.POST.get("newPassword")
|
||||||
|
repeatPassword = request.POST.get("repeatNewPassword")
|
||||||
|
|
||||||
|
serializer_class = UserPasswordResetConfirmSerializer
|
||||||
|
permission_classes = (permissions.AllowAny,)
|
||||||
|
token_generator = default_token_generator
|
||||||
|
return redirect('login')
|
||||||
|
return render(request, 'resetPasswordConfirm.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user