change password

This commit is contained in:
Administrator 2023-09-23 19:56:14 +03:00
parent 9871dbb9cc
commit a841847613
2 changed files with 11 additions and 3 deletions

View File

@ -44,14 +44,14 @@
<p style="padding-top: 8px; font-size: 24px;">{{ account.date_joined.date }}</p>
</td>
</tr>
{% if owner %}
{% if owner and False %}
<tr>
<td>
<h2><i class="fa fa-users"></i></h2>
</td>
<td><div style="width: 20px;"></div></td>
<td>
<a href="https://oauth.vk.com/authorize?client_id=51755822&redirect_uri=https://platform.sprinthub.ru/vk_auth&display=page&response_type=token&v=5.59';"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/VK_Compact_Logo_%282021-present%29.svg/1200px-VK_Compact_Logo_%282021-present%29.svg.png"></a>
<a href="https://oauth.vk.com/authorize?client_id=51755832&redirect_uri=http://127.0.0.1:8000/vk_auth&display=page&response_type=token&v=5.59';"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/VK_Compact_Logo_%282021-present%29.svg/1200px-VK_Compact_Logo_%282021-present%29.svg.png"></a>
{% if account.vk_id %}
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>
{% endif %}
@ -97,10 +97,15 @@
<h1 class="h4" style="margin-bottom: 40px;">Сменить пароль</h1>
<div class="row">
<div class="col-4">
{% if err %}
<div class="alert alert-danger" role="alert">
Пароли не совпадают
</div>
{% endif %}
<form method="POST">
{% csrf_token %}
<input class="form-control" name="password" type="password" placeholder="Новый пароль">
<input style="margin-top: 5px; margin-bottom: 5px;" class="form-control" type="password" placeholder="Повтори пароль">
<input style="margin-top: 5px; margin-bottom: 5px;" class="form-control" name="repeat" type="password" placeholder="Повтори пароль">
<button type="submit" name="action" value="change_password" class="btn btn-primary">Сохранить</button>
</form>
</div>

View File

@ -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)