forked from hts1238/yandex_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrationWindow.py
More file actions
53 lines (47 loc) · 1.76 KB
/
RegistrationWindow.py
File metadata and controls
53 lines (47 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from registration_request import registration_request
from send_email import send_email
from generate_password import generate_password
from check_password import check_password
from check_handle import check_handle
from files import *
from PyQt5.QtCore import Qt
from PyQt5 import uic
from PyQt5.QtWidgets import QDialog
class RegistrationWindow(QDialog):
"""
Класс окна регистрации пользователя
"""
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
uic.loadUi(REGISTRATION_UI, self)
self.setWindowFlags(Qt.WindowMaximizeButtonHint)
self.ok_btn.clicked.connect(self.run)
self.password_text.setText(generate_password(15))
def run(self):
"""
Выполняет процесс регистрации пользователя, ели это возможно
:return: None
"""
email = self.email_text.text()
name = self.name_text.text()
handle = self.handle_text.text()
password = self.password_text.text()
if not check_handle(password):
self.handle_corr.setText('Incorrect')
self.handle_corr.setStyleSheet('color: red')
return
if not check_password(password):
self.password.setText('Incorrect')
self.password.setStyleSheet('color: red')
return
answer = registration_request(email, name, handle, password)
if 'Error' not in answer:
send_email(name, handle, password, email)
self.token = answer['token']
print(self.token)
self.close()
else:
self.handle_corr.setText('Incorrect')
self.handle_corr.setStyleSheet('color: red')