From a8418476135db3350694ca5ae49574798e2ed607 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 23 Sep 2023 19:56:14 +0300 Subject: [PATCH] change password --- templates/profile.html | 11 ++++++++--- web/views/profile.py | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/templates/profile.html b/templates/profile.html index 32f23bb..22c987d 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -44,14 +44,14 @@

{{ account.date_joined.date }}

- {% if owner %} + {% if owner and False %}

- + {% if account.vk_id %}
{% endif %} @@ -97,10 +97,15 @@

Сменить пароль

+ {% if err %} + + {% endif %}
{% csrf_token %} - +
diff --git a/web/views/profile.py b/web/views/profile.py index 932bd88..1713f55 100644 --- a/web/views/profile.py +++ b/web/views/profile.py @@ -10,6 +10,7 @@ class ProfileView(BaseView): view_file = 'profile.html' def get(self): + self.context['err'] = 'err' in self.request.GET self.context['owner'] = not hasattr(self, 'customUser') or self.customUser == self.request.user self.context['account'] = getattr(self, 'customUser', None) or self.request.user @@ -18,6 +19,8 @@ class ProfileView(BaseView): return self def post_change_password(self): + if self.request.POST['password'] != self.request.POST['repeat']: + return '/profile?err=true' self.request.user.set_password(self.request.POST['password']) self.request.user.save() login(self.request, self.request.user)