change password
This commit is contained in:
parent
9871dbb9cc
commit
a841847613
@ -44,14 +44,14 @@
|
|||||||
<p style="padding-top: 8px; font-size: 24px;">{{ account.date_joined.date }}</p>
|
<p style="padding-top: 8px; font-size: 24px;">{{ account.date_joined.date }}</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if owner %}
|
{% if owner and False %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h2><i class="fa fa-users"></i></h2>
|
<h2><i class="fa fa-users"></i></h2>
|
||||||
</td>
|
</td>
|
||||||
<td><div style="width: 20px;"></div></td>
|
<td><div style="width: 20px;"></div></td>
|
||||||
<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 %}
|
{% if account.vk_id %}
|
||||||
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>
|
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -97,10 +97,15 @@
|
|||||||
<h1 class="h4" style="margin-bottom: 40px;">Сменить пароль</h1>
|
<h1 class="h4" style="margin-bottom: 40px;">Сменить пароль</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
{% if err %}
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
Пароли не совпадают
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input class="form-control" name="password" type="password" placeholder="Новый пароль">
|
<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>
|
<button type="submit" name="action" value="change_password" class="btn btn-primary">Сохранить</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,7 @@ class ProfileView(BaseView):
|
|||||||
view_file = 'profile.html'
|
view_file = 'profile.html'
|
||||||
|
|
||||||
def get(self):
|
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['owner'] = not hasattr(self, 'customUser') or self.customUser == self.request.user
|
||||||
self.context['account'] = getattr(self, 'customUser', None) or self.request.user
|
self.context['account'] = getattr(self, 'customUser', None) or self.request.user
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ class ProfileView(BaseView):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def post_change_password(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.set_password(self.request.POST['password'])
|
||||||
self.request.user.save()
|
self.request.user.save()
|
||||||
login(self.request, self.request.user)
|
login(self.request, self.request.user)
|
||||||
|
Loading…
Reference in New Issue
Block a user