change password removed
This commit is contained in:
parent
c76daddd98
commit
0e9aa2b319
@ -1,4 +1,3 @@
|
|||||||
from django.contrib.auth import authenticate, login
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
from SprintLib.BaseView import BaseView
|
from SprintLib.BaseView import BaseView
|
||||||
@ -33,23 +32,7 @@ class AccountView(BaseView):
|
|||||||
self.request.user.userinfo.save()
|
self.request.user.userinfo.save()
|
||||||
return "/account"
|
return "/account"
|
||||||
|
|
||||||
def post_change_password(self):
|
|
||||||
password = self.request.POST["password"].strip()
|
|
||||||
new_password = self.request.POST["new_password"].strip()
|
|
||||||
user = authenticate(username=self.request.user.username, password=password)
|
|
||||||
if not user:
|
|
||||||
return "/account?error_message=Неправильно указан пароль"
|
|
||||||
if len(new_password) < 8:
|
|
||||||
return "/account?error_message=Пароль слишком слабый"
|
|
||||||
if new_password != self.request.POST["repeat"]:
|
|
||||||
return "/account?error_message=Пароли не совпадают"
|
|
||||||
self.request.user.set_password(new_password)
|
|
||||||
self.request.user.save()
|
|
||||||
login(self.request, self.request.user)
|
|
||||||
return "/account?error_message=Пароль успешно установлен"
|
|
||||||
|
|
||||||
def post_notifications(self):
|
def post_notifications(self):
|
||||||
self.request.user.userinfo.telegram_chat_id = self.request.POST['chat_id']
|
|
||||||
for attr in dir(self.request.user.userinfo):
|
for attr in dir(self.request.user.userinfo):
|
||||||
if attr.startswith('notification'):
|
if attr.startswith('notification'):
|
||||||
setattr(self.request.user.userinfo, attr, attr in self.request.POST.keys())
|
setattr(self.request.user.userinfo, attr, attr in self.request.POST.keys())
|
||||||
|
@ -95,26 +95,12 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr><hr>
|
|
||||||
{% if owner %}
|
|
||||||
<p style="color: red;">{{ error_message }}</p>
|
|
||||||
<form method="POST">
|
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="action" value="change_password">
|
|
||||||
<h2 style="margin-bottom: 40px; margin-top: 40px;">Смена пароля</h2>
|
|
||||||
<input type="password" placeholder="Текущий пароль" name="password" style="margin-bottom: 20px; width: 300px;"><br>
|
|
||||||
<input type="password" placeholder="Новый пароль" name="new_password" style="margin-bottom: 20px; width: 300px;"><br>
|
|
||||||
<input type="password" placeholder="Повторить пароль" name="repeat" style="margin-bottom: 20px; width: 300px;"><br>
|
|
||||||
<button type="submit" class="btn btn-light">Сменить пароль</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
{% if owner %}
|
{% if owner %}
|
||||||
<hr><hr>
|
<hr><hr>
|
||||||
<h2>Уведомления</h2>
|
<h2>Уведомления</h2>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="action" value="notifications">
|
<input type="hidden" name="action" value="notifications">
|
||||||
<input type="text" name="chat_id" value="{{ user.userinfo.telegram_chat_id }}" placeholder="telegram chat id"> <a class="btn btn-link" target="_blank" rel="noopener noreferrer" href="https://t.me/sprint_notifications_bot">Бот</a>
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 200px;">
|
<td style="width: 200px;">
|
||||||
|
Loading…
Reference in New Issue
Block a user