edycja hasła
This commit is contained in:
parent
50190ef354
commit
a40df66886
Binary file not shown.
Binary file not shown.
159
SocialHelper/homepage/templates/homepage/edit_user.html
Normal file
159
SocialHelper/homepage/templates/homepage/edit_user.html
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block content %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!--================Categories Banner Area =================-->
|
||||||
|
<section class="solid_banner_area">
|
||||||
|
<div class="container">
|
||||||
|
<div class="solid_banner_inner">
|
||||||
|
<h3>Zmień hasło</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<!--================End Categories Banner Area =================-->
|
||||||
|
|
||||||
|
<!--================Register Area =================-->
|
||||||
|
<form action="{% url 'edit_user' %}" method="POST" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.media }}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<input type="hidden" name="email" value="">
|
||||||
|
<input type="hidden" name="password" value="">
|
||||||
|
<section class="track_area p_100">
|
||||||
|
<div class="container">
|
||||||
|
<div class="track_inner">
|
||||||
|
<form class="track_form row">
|
||||||
|
|
||||||
|
<div class="container h-100">
|
||||||
|
<div class="row h-100 justify-content-center align-items-center">
|
||||||
|
<div class="col-10 col-md-8 col-lg-6">
|
||||||
|
<label for="name">Obecne hasło: <span>*</span></label>
|
||||||
|
<input type="password" class="form-control" id="password" aria-describedby="name" placeholder="" name="oldpassword">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container h-100">
|
||||||
|
<div class="row h-100 justify-content-center align-items-center">
|
||||||
|
<div class="col-10 col-md-8 col-lg-6">
|
||||||
|
<label for="name">Nowe hasło: <span>*</span></label>
|
||||||
|
<input type="password" class="form-control" id="name" aria-describedby="name" placeholder="" name="newpassword1">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container h-100">
|
||||||
|
<div class="row h-100 justify-content-center align-items-center">
|
||||||
|
<div class="col-10 col-md-8 col-lg-6">
|
||||||
|
<label for="name">Potwierdź nowe hasło: <span>*</span></label>
|
||||||
|
<input type="password" class="form-control" id="name" aria-describedby="name" placeholder="" name="newpassword2">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container h-100">
|
||||||
|
<div class="row h-100 justify-content-center align-items-center">
|
||||||
|
<div class="col-10 col-md-8 col-lg-6">
|
||||||
|
<input type="submit" class="btn btn-primary update_btn" value="Zmień">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</form>
|
||||||
|
<!--================End Track Area =================-->
|
||||||
|
<!--================End Register Area =================-->
|
||||||
|
|
||||||
|
<!--================Footer Area =================-->
|
||||||
|
<footer class="footer_area">
|
||||||
|
<div class="container">
|
||||||
|
<div class="footer_widgets">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-4 col-md-4 col-6">
|
||||||
|
<aside class="f_widget f_about_widget">
|
||||||
|
<img src="img/logo.png" alt="">
|
||||||
|
<p>Persuit is a Premium PSD Template. Best choice for your online store. Let purchase it to enjoy now</p>
|
||||||
|
<h6>Social:</h6>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#"><i class="social_facebook"></i></a></li>
|
||||||
|
<li><a href="#"><i class="social_twitter"></i></a></li>
|
||||||
|
<li><a href="#"><i class="social_pinterest"></i></a></li>
|
||||||
|
<li><a href="#"><i class="social_instagram"></i></a></li>
|
||||||
|
<li><a href="#"><i class="social_youtube"></i></a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-4 col-6">
|
||||||
|
<aside class="f_widget link_widget f_info_widget">
|
||||||
|
<div class="f_w_title">
|
||||||
|
<h3>Information</h3>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">About us</a></li>
|
||||||
|
<li><a href="#">Delivery information</a></li>
|
||||||
|
<li><a href="#">Terms & Conditions</a></li>
|
||||||
|
<li><a href="#">Help Center</a></li>
|
||||||
|
<li><a href="#">Returns & Refunds</a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-4 col-6">
|
||||||
|
<aside class="f_widget link_widget f_service_widget">
|
||||||
|
<div class="f_w_title">
|
||||||
|
<h3>Customer Service</h3>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">My account</a></li>
|
||||||
|
<li><a href="#">Ordr History</a></li>
|
||||||
|
<li><a href="#">Wish List</a></li>
|
||||||
|
<li><a href="#">Newsletter</a></li>
|
||||||
|
<li><a href="#">Contact Us</a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-4 col-6">
|
||||||
|
<aside class="f_widget link_widget f_extra_widget">
|
||||||
|
<div class="f_w_title">
|
||||||
|
<h3>Extras</h3>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">Brands</a></li>
|
||||||
|
<li><a href="#">Gift Vouchers</a></li>
|
||||||
|
<li><a href="#">Affiliates</a></li>
|
||||||
|
<li><a href="#">Specials</a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-4 col-6">
|
||||||
|
<aside class="f_widget link_widget f_account_widget">
|
||||||
|
<div class="f_w_title">
|
||||||
|
<h3>My Account</h3>
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">My account</a></li>
|
||||||
|
<li><a href="#">Ordr History</a></li>
|
||||||
|
<li><a href="#">Wish List</a></li>
|
||||||
|
<li><a href="#">Newsletter</a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="footer_copyright">
|
||||||
|
<h5>© <script>document.write(new Date().getFullYear());</script> <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||||
|
Copyright ©<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>. Downloaded from <a href="https://themeslab.org/" target="_blank">Themeslab</a>
|
||||||
|
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<!--================End Footer Area =================-->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{% endblock %}
|
@ -62,7 +62,9 @@
|
|||||||
<p>No polls are available.</p>
|
<p>No polls are available.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<br><a href="delete_user"><button type="button" class="btn btn-danger pull-right">Usuń Konto</button></a>
|
<br>
|
||||||
|
<a href="delete_user"><button type="button" class="btn btn-danger pull-right">Usuń Konto</button></a>
|
||||||
|
<a href="edit_user"><button type="button" class="btn btn-primary pull-right">Zmień Hasło</button></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="{% url 'filter' %}" method="post">
|
<form action="{% url 'filter' %}" method="post">
|
||||||
|
@ -24,5 +24,6 @@ urlpatterns = [
|
|||||||
path('delete_user', views.delete_user, name='delete_user'),
|
path('delete_user', views.delete_user, name='delete_user'),
|
||||||
path('logout_user', views.logout_user, name='logout_user'),
|
path('logout_user', views.logout_user, name='logout_user'),
|
||||||
path('<int:user_id>/delete_user', views.delete_user, name='delete_user'),
|
path('<int:user_id>/delete_user', views.delete_user, name='delete_user'),
|
||||||
|
path('edit_user', views.edit_user, name='edit_user'),
|
||||||
|
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -361,8 +361,50 @@ def delete_user(request):
|
|||||||
messages.success(request,'Konto skasowane!')
|
messages.success(request,'Konto skasowane!')
|
||||||
return redirect(index)
|
return redirect(index)
|
||||||
|
|
||||||
def edit_user(request, user_id):
|
def edit_user(request):
|
||||||
return True
|
User = get_user_model()
|
||||||
|
instant = User.objects.filter(id=request.user.id).first()
|
||||||
|
if request.method == 'POST':
|
||||||
|
|
||||||
|
oldpassword = request.POST['oldpassword']
|
||||||
|
newpassword1 = request.POST['newpassword1']
|
||||||
|
newpassword2 = request.POST['newpassword2']
|
||||||
|
user = authenticate(request, username=instant.username, password=oldpassword, is_active=True)
|
||||||
|
if user is None:
|
||||||
|
messages.error(request,'Podałeś złe hasło')
|
||||||
|
return redirect('edit_user')
|
||||||
|
|
||||||
|
dlugosc = 0
|
||||||
|
znak = 0
|
||||||
|
duza = 0
|
||||||
|
mala = 0
|
||||||
|
cyfra = 0
|
||||||
|
for i in newpassword1:
|
||||||
|
if i in "1234567890":
|
||||||
|
cyfra = 1
|
||||||
|
elif i in "QWERTYUIOPASDFGHJKLZXCVBNM":
|
||||||
|
duza = 1
|
||||||
|
elif i in "qwertyuiopasdfghjklzxcvbnm":
|
||||||
|
mala = 1
|
||||||
|
elif i in "!@#$%&*(){}[]<>?":
|
||||||
|
znak = 1
|
||||||
|
if len(newpassword1) >= 8:
|
||||||
|
dlugosc = 1
|
||||||
|
|
||||||
|
if dlugosc+znak+mala+duza+cyfra != 5:
|
||||||
|
messages.error(request,'Podane hasło jest nieprawidłowe. Hasło musi zawierać conajmniej: 1 cyfre, 1 duza litere, 1 mala litere, 1 znak specjalny z zakresu !@#$%&*(){}[]<>?, oraz składać sie conajmniej z 8 symboli')
|
||||||
|
return redirect('edit_user')
|
||||||
|
|
||||||
|
if newpassword1 != newpassword2:
|
||||||
|
messages.error(request,'Podane nowe hasła są różne')
|
||||||
|
return redirect('edit_user')
|
||||||
|
|
||||||
|
instant.set_password(newpassword1)
|
||||||
|
instant.save()
|
||||||
|
messages.success(request,'Hasło zmienione, nastąpiło wylogowanie!')
|
||||||
|
return redirect('my_offer')
|
||||||
|
|
||||||
|
return render(request , 'homepage/edit_user.html')
|
||||||
|
|
||||||
def login(request):
|
def login(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
Loading…
Reference in New Issue
Block a user