Spaces:
Sleeping
Sleeping
a-v-bely
commited on
Commit
•
fe99633
1
Parent(s):
8c2ed38
Update app
Browse files- utilities/__pycache__/utils.cpython-310.pyc +0 -0
- utilities_cookies/__pycache__/cookie_manager.cpython-310.pyc +0 -0
- utilities_cookies/__pycache__/encrypted_cookie_manager.cpython-310.pyc +0 -0
- utilities_database/__pycache__/user_database_utils.cpython-310.pyc +0 -0
- utilities_database/__pycache__/user_database_widgets.cpython-310.pyc +0 -0
- utilities_database/user_database_utils.py +57 -50
- utilities_database/user_database_widgets.py +15 -16
- utilities_language_general/__pycache__/esp_constants.cpython-310.pyc +0 -0
- utilities_language_general/__pycache__/esp_utils.cpython-310.pyc +0 -0
- utilities_language_general/__pycache__/morphology.cpython-310.pyc +0 -0
- utilities_language_w2v/__pycache__/esp_main_workflow_w2v.cpython-310.pyc +0 -0
- utilities_language_w2v/__pycache__/esp_sentence_w2v.cpython-310.pyc +0 -0
- utilities_option_menu/__pycache__/option_menu.cpython-310.pyc +0 -0
- utilities_ui/__pycache__/custom_download_button.cpython-310.pyc +0 -0
- Вход.py +11 -9
utilities/__pycache__/utils.cpython-310.pyc
CHANGED
Binary files a/utilities/__pycache__/utils.cpython-310.pyc and b/utilities/__pycache__/utils.cpython-310.pyc differ
|
|
utilities_cookies/__pycache__/cookie_manager.cpython-310.pyc
CHANGED
Binary files a/utilities_cookies/__pycache__/cookie_manager.cpython-310.pyc and b/utilities_cookies/__pycache__/cookie_manager.cpython-310.pyc differ
|
|
utilities_cookies/__pycache__/encrypted_cookie_manager.cpython-310.pyc
CHANGED
Binary files a/utilities_cookies/__pycache__/encrypted_cookie_manager.cpython-310.pyc and b/utilities_cookies/__pycache__/encrypted_cookie_manager.cpython-310.pyc differ
|
|
utilities_database/__pycache__/user_database_utils.cpython-310.pyc
CHANGED
Binary files a/utilities_database/__pycache__/user_database_utils.cpython-310.pyc and b/utilities_database/__pycache__/user_database_utils.cpython-310.pyc differ
|
|
utilities_database/__pycache__/user_database_widgets.cpython-310.pyc
CHANGED
Binary files a/utilities_database/__pycache__/user_database_widgets.cpython-310.pyc and b/utilities_database/__pycache__/user_database_widgets.cpython-310.pyc differ
|
|
utilities_database/user_database_utils.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import re
|
|
|
2 |
import secrets
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
@@ -13,17 +14,20 @@ def check_usr_pass(user_log_in_database, user_name: str, password: str) -> bool:
|
|
13 |
"""
|
14 |
Authenticates the user_name and password.
|
15 |
"""
|
16 |
-
registered_user = user_log_in_database.
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return False
|
22 |
-
except VerifyMismatchError:
|
23 |
-
pass
|
24 |
-
except IndexError:
|
25 |
-
pass
|
26 |
-
return False
|
27 |
|
28 |
|
29 |
def check_valid_name(name_sign_up: str) -> bool:
|
@@ -40,7 +44,7 @@ def check_valid_name(name_sign_up: str) -> bool:
|
|
40 |
|
41 |
def check_valid_email(email_sign_up: str) -> bool:
|
42 |
"""
|
43 |
-
Checks if the user entered a valid
|
44 |
"""
|
45 |
regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
|
46 |
return True
|
@@ -52,9 +56,9 @@ def check_valid_email(email_sign_up: str) -> bool:
|
|
52 |
|
53 |
def check_unique_email(user_log_in_database, email_sign_up: str) -> bool:
|
54 |
"""
|
55 |
-
Checks if the
|
56 |
"""
|
57 |
-
authorized_users_data = user_log_in_database.
|
58 |
if len(authorized_users_data) == 0:
|
59 |
return True
|
60 |
return False
|
@@ -80,11 +84,9 @@ def check_unique_usr(user_log_in_database, user_name_sign_up: str):
|
|
80 |
Checks if the user_name already exists (since user_name needs to be unique),
|
81 |
also checks for non-empty user_name.
|
82 |
"""
|
83 |
-
authorized_users_data = user_log_in_database.
|
84 |
if len(authorized_users_data) != 0:
|
85 |
return False
|
86 |
-
if user_name_sign_up in authorized_users_data:
|
87 |
-
return False
|
88 |
non_empty_check = non_empty_str_check(user_name_sign_up)
|
89 |
if not non_empty_check:
|
90 |
return None
|
@@ -98,19 +100,19 @@ def register_new_usr(user_log_in_database, name_sign_up: str, email_sign_up: str
|
|
98 |
"""
|
99 |
new_usr_data = {'user_name': user_name_sign_up,
|
100 |
'name': name_sign_up,
|
101 |
-
'
|
102 |
'password': ph.hash(password_sign_up),
|
103 |
'professional_level': professional_level,
|
104 |
-
'
|
105 |
|
106 |
-
return user_log_in_database.
|
107 |
|
108 |
|
109 |
def check_user_name_exists(user_log_in_database, user_name: str) -> bool:
|
110 |
"""
|
111 |
Checks if the user_name exists in the _secret_auth.json file.
|
112 |
"""
|
113 |
-
authorized_users_data = user_log_in_database.
|
114 |
if len(authorized_users_data) == 1:
|
115 |
return True
|
116 |
return False
|
@@ -118,9 +120,9 @@ def check_user_name_exists(user_log_in_database, user_name: str) -> bool:
|
|
118 |
|
119 |
def check_email_exists(user_log_in_database, email_forgot_passwd: str):
|
120 |
"""
|
121 |
-
Checks if the
|
122 |
"""
|
123 |
-
authorized_users_data = user_log_in_database.
|
124 |
if len(authorized_users_data) == 1:
|
125 |
return True, authorized_users_data[0]['user_name']
|
126 |
return False, None
|
@@ -128,7 +130,7 @@ def check_email_exists(user_log_in_database, email_forgot_passwd: str):
|
|
128 |
|
129 |
def generate_random_passwd() -> str:
|
130 |
"""
|
131 |
-
Generates a random password to be sent in
|
132 |
"""
|
133 |
password_length = 10
|
134 |
return secrets.token_urlsafe(password_length)
|
@@ -137,7 +139,7 @@ def generate_random_passwd() -> str:
|
|
137 |
def send_passwd_in_email(auth_token: str, user_name_forgot_passwd: str, email_forgot_passwd: str, company_name: str,
|
138 |
random_password: str) -> None:
|
139 |
"""
|
140 |
-
Triggers an
|
141 |
"""
|
142 |
client = Courier(auth_token=auth_token)
|
143 |
|
@@ -162,9 +164,8 @@ def change_passwd(user_log_in_database, email_forgot_passwd: str, random_passwor
|
|
162 |
"""
|
163 |
Replaces the old password with the newly generated password.
|
164 |
"""
|
165 |
-
user_key = user_log_in_database.fetch({'e-mail': email_forgot_passwd}).items[0]['key']
|
166 |
updates = {'password': ph.hash(random_password)}
|
167 |
-
return user_log_in_database.update(updates,
|
168 |
|
169 |
|
170 |
def check_current_passwd(user_log_in_database, email_reset_passwd: str, current_passwd: str = None) -> bool:
|
@@ -172,7 +173,7 @@ def check_current_passwd(user_log_in_database, email_reset_passwd: str, current_
|
|
172 |
Authenticates the password entered against the user_name when
|
173 |
resetting the password.
|
174 |
"""
|
175 |
-
authorized_user_data = user_log_in_database.
|
176 |
if current_passwd is None:
|
177 |
current_passwd = 'b'
|
178 |
try:
|
@@ -183,18 +184,23 @@ def check_current_passwd(user_log_in_database, email_reset_passwd: str, current_
|
|
183 |
return False
|
184 |
|
185 |
|
186 |
-
def save_data_in_database(user_task_database, save_type, save_name, cefr_level,
|
187 |
generated_result=None, test_taker_name=None, test_taker_answers=None, test_taker_result=None,
|
188 |
comments=None, distractor_model=None, allow=False):
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
if save_name == '' and save_type == 'download':
|
199 |
save_name = generated_result['name']
|
200 |
if len(already_saved_names) != 0 and save_type == 'download':
|
@@ -210,7 +216,7 @@ def save_data_in_database(user_task_database, save_type, save_name, cefr_level,
|
|
210 |
'save_type': save_type,
|
211 |
'save_name': save_name,
|
212 |
'cefr_level': cefr_level,
|
213 |
-
'
|
214 |
'creator_name': creator_name,
|
215 |
'generated_result': generated_result,
|
216 |
'distractor_model': distractor_model
|
@@ -220,14 +226,14 @@ def save_data_in_database(user_task_database, save_type, save_name, cefr_level,
|
|
220 |
'save_type': save_type,
|
221 |
'save_name': save_name,
|
222 |
'cefr_level': cefr_level,
|
223 |
-
'
|
224 |
'creator_name': creator_name,
|
225 |
'test_taker_name': test_taker_name,
|
226 |
'test_taker_answers': test_taker_answers,
|
227 |
'generated_result': generated_result,
|
228 |
'test_taker_result': test_taker_result,
|
229 |
'comments': comments}
|
230 |
-
user_task_database.
|
231 |
if save_type == 'download':
|
232 |
if allow:
|
233 |
return st.success('Задания успешно сохранены! Можете переходить на следующие вкладки')
|
@@ -237,27 +243,28 @@ def save_data_in_database(user_task_database, save_type, save_name, cefr_level,
|
|
237 |
|
238 |
def load_user_tasks_data(user_task_database, save_type, creator_name=None, test_taker_name=None):
|
239 |
if save_type == 'download':
|
240 |
-
user_data = user_task_database.
|
241 |
names = [item['save_name'] for item in user_data]
|
242 |
cefr_level = [item['cefr_level'] for item in user_data]
|
243 |
-
|
244 |
-
return_data = pd.DataFrame([names, cefr_level,
|
245 |
return_data.columns = ['Название', 'Уровень', 'Время создания']
|
246 |
else:
|
247 |
-
user_data = user_task_database.
|
248 |
names = [item['save_name'] for item in user_data]
|
249 |
cefr_level = [item['cefr_level'] for item in user_data]
|
250 |
-
|
251 |
creator_name = [item['creator_name'] for item in user_data]
|
252 |
test_taker_result = [item['test_taker_result'] for item in user_data]
|
253 |
-
return_data = pd.DataFrame([names, cefr_level, test_taker_result,
|
254 |
return_data.columns = ['Название', 'Уровень', 'Оценка', 'Дата прохождения', 'Автор заданий']
|
255 |
return return_data
|
256 |
|
257 |
|
258 |
def load_users_particular_task(user_task_database, load_mode, creator_name, save_name, cefr_level,):
|
259 |
-
return_data = user_task_database.
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
263 |
return return_data
|
|
|
1 |
import re
|
2 |
+
import json
|
3 |
import secrets
|
4 |
import pandas as pd
|
5 |
import streamlit as st
|
|
|
14 |
"""
|
15 |
Authenticates the user_name and password.
|
16 |
"""
|
17 |
+
registered_user = user_log_in_database.select('*').eq('user_name', user_name).execute()
|
18 |
+
if not registered_user.data:
|
19 |
+
return False
|
20 |
+
else:
|
21 |
+
try:
|
22 |
+
passwd_verification_bool = ph.verify(registered_user.data[0]['password'], password)
|
23 |
+
if passwd_verification_bool:
|
24 |
+
return True
|
25 |
+
return False
|
26 |
+
except VerifyMismatchError:
|
27 |
+
pass
|
28 |
+
except IndexError:
|
29 |
+
pass
|
30 |
return False
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
|
33 |
def check_valid_name(name_sign_up: str) -> bool:
|
|
|
44 |
|
45 |
def check_valid_email(email_sign_up: str) -> bool:
|
46 |
"""
|
47 |
+
Checks if the user entered a valid email while creating the account.
|
48 |
"""
|
49 |
regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
|
50 |
return True
|
|
|
56 |
|
57 |
def check_unique_email(user_log_in_database, email_sign_up: str) -> bool:
|
58 |
"""
|
59 |
+
Checks if the email already exists (since email needs to be unique).
|
60 |
"""
|
61 |
+
authorized_users_data = user_log_in_database.select('*').eq('email', email_sign_up).execute().data
|
62 |
if len(authorized_users_data) == 0:
|
63 |
return True
|
64 |
return False
|
|
|
84 |
Checks if the user_name already exists (since user_name needs to be unique),
|
85 |
also checks for non-empty user_name.
|
86 |
"""
|
87 |
+
authorized_users_data = user_log_in_database.select('*').eq('user_name', user_name_sign_up).execute().data
|
88 |
if len(authorized_users_data) != 0:
|
89 |
return False
|
|
|
|
|
90 |
non_empty_check = non_empty_str_check(user_name_sign_up)
|
91 |
if not non_empty_check:
|
92 |
return None
|
|
|
100 |
"""
|
101 |
new_usr_data = {'user_name': user_name_sign_up,
|
102 |
'name': name_sign_up,
|
103 |
+
'email': email_sign_up,
|
104 |
'password': ph.hash(password_sign_up),
|
105 |
'professional_level': professional_level,
|
106 |
+
'created_at': timestamp}
|
107 |
|
108 |
+
return user_log_in_database.insert(new_usr_data).execute()
|
109 |
|
110 |
|
111 |
def check_user_name_exists(user_log_in_database, user_name: str) -> bool:
|
112 |
"""
|
113 |
Checks if the user_name exists in the _secret_auth.json file.
|
114 |
"""
|
115 |
+
authorized_users_data = user_log_in_database.select('*').eq('user_name', user_name).execute().data
|
116 |
if len(authorized_users_data) == 1:
|
117 |
return True
|
118 |
return False
|
|
|
120 |
|
121 |
def check_email_exists(user_log_in_database, email_forgot_passwd: str):
|
122 |
"""
|
123 |
+
Checks if the email entered is present in the _secret_auth.json file.
|
124 |
"""
|
125 |
+
authorized_users_data = user_log_in_database.select('*').eq('email', email_forgot_passwd).execute().data
|
126 |
if len(authorized_users_data) == 1:
|
127 |
return True, authorized_users_data[0]['user_name']
|
128 |
return False, None
|
|
|
130 |
|
131 |
def generate_random_passwd() -> str:
|
132 |
"""
|
133 |
+
Generates a random password to be sent in email.
|
134 |
"""
|
135 |
password_length = 10
|
136 |
return secrets.token_urlsafe(password_length)
|
|
|
139 |
def send_passwd_in_email(auth_token: str, user_name_forgot_passwd: str, email_forgot_passwd: str, company_name: str,
|
140 |
random_password: str) -> None:
|
141 |
"""
|
142 |
+
Triggers an email to the user containing the randomly generated password.
|
143 |
"""
|
144 |
client = Courier(auth_token=auth_token)
|
145 |
|
|
|
164 |
"""
|
165 |
Replaces the old password with the newly generated password.
|
166 |
"""
|
|
|
167 |
updates = {'password': ph.hash(random_password)}
|
168 |
+
return user_log_in_database.update(updates).eq('email', email_forgot_passwd).execute()
|
169 |
|
170 |
|
171 |
def check_current_passwd(user_log_in_database, email_reset_passwd: str, current_passwd: str = None) -> bool:
|
|
|
173 |
Authenticates the password entered against the user_name when
|
174 |
resetting the password.
|
175 |
"""
|
176 |
+
authorized_user_data = user_log_in_database.select('*').eq('email', email_reset_passwd).execute().data[0]
|
177 |
if current_passwd is None:
|
178 |
current_passwd = 'b'
|
179 |
try:
|
|
|
184 |
return False
|
185 |
|
186 |
|
187 |
+
def save_data_in_database(user_task_database, save_type, save_name, cefr_level, created_at, creator_name=None,
|
188 |
generated_result=None, test_taker_name=None, test_taker_answers=None, test_taker_result=None,
|
189 |
comments=None, distractor_model=None, allow=False):
|
190 |
+
already_saved = user_task_database.select('*').execute().data
|
191 |
+
already_saved_names = [task for task in already_saved
|
192 |
+
if (task['creator_name']==creator_name
|
193 |
+
& task['save_name']==save_name
|
194 |
+
& task['cefr_level']==cefr_level)]
|
195 |
+
already_saved_tasks = [task for task in already_saved
|
196 |
+
if (task['creator_name']==creator_name
|
197 |
+
& task['generated_result']==generated_result
|
198 |
+
& task['cefr_level']==cefr_level)]
|
199 |
+
already_saved_tests = [task for task in already_saved
|
200 |
+
if (task['test_taker_name']==test_taker_name
|
201 |
+
& task['save_name']==save_name
|
202 |
+
& task['cefr_level']==cefr_level)]
|
203 |
+
|
204 |
if save_name == '' and save_type == 'download':
|
205 |
save_name = generated_result['name']
|
206 |
if len(already_saved_names) != 0 and save_type == 'download':
|
|
|
216 |
'save_type': save_type,
|
217 |
'save_name': save_name,
|
218 |
'cefr_level': cefr_level,
|
219 |
+
'created_at': created_at,
|
220 |
'creator_name': creator_name,
|
221 |
'generated_result': generated_result,
|
222 |
'distractor_model': distractor_model
|
|
|
226 |
'save_type': save_type,
|
227 |
'save_name': save_name,
|
228 |
'cefr_level': cefr_level,
|
229 |
+
'created_at': created_at,
|
230 |
'creator_name': creator_name,
|
231 |
'test_taker_name': test_taker_name,
|
232 |
'test_taker_answers': test_taker_answers,
|
233 |
'generated_result': generated_result,
|
234 |
'test_taker_result': test_taker_result,
|
235 |
'comments': comments}
|
236 |
+
user_task_database.insert(new_save_data).execute()
|
237 |
if save_type == 'download':
|
238 |
if allow:
|
239 |
return st.success('Задания успешно сохранены! Можете переходить на следующие вкладки')
|
|
|
243 |
|
244 |
def load_user_tasks_data(user_task_database, save_type, creator_name=None, test_taker_name=None):
|
245 |
if save_type == 'download':
|
246 |
+
user_data = user_task_database.select('*').eq('creator_name', creator_name).eq('save_type', save_type).execute().data
|
247 |
names = [item['save_name'] for item in user_data]
|
248 |
cefr_level = [item['cefr_level'] for item in user_data]
|
249 |
+
created_ats = [item['created_at'] for item in user_data]
|
250 |
+
return_data = pd.DataFrame([names, cefr_level, created_ats]).transpose()
|
251 |
return_data.columns = ['Название', 'Уровень', 'Время создания']
|
252 |
else:
|
253 |
+
user_data = user_task_database.select('*').eq('test_taker_name', test_taker_name).eq('save_type', save_type).execute().data
|
254 |
names = [item['save_name'] for item in user_data]
|
255 |
cefr_level = [item['cefr_level'] for item in user_data]
|
256 |
+
created_ats = [item['created_at'] for item in user_data]
|
257 |
creator_name = [item['creator_name'] for item in user_data]
|
258 |
test_taker_result = [item['test_taker_result'] for item in user_data]
|
259 |
+
return_data = pd.DataFrame([names, cefr_level, test_taker_result, created_ats, creator_name]).transpose()
|
260 |
return_data.columns = ['Название', 'Уровень', 'Оценка', 'Дата прохождения', 'Автор заданий']
|
261 |
return return_data
|
262 |
|
263 |
|
264 |
def load_users_particular_task(user_task_database, load_mode, creator_name, save_name, cefr_level,):
|
265 |
+
return_data = user_task_database.select('*').eq('creator_name', creator_name)\
|
266 |
+
.eq('save_name', save_name)\
|
267 |
+
.eq('save_type', load_mode)\
|
268 |
+
.eq('cefr_level',cefr_level).execute().data[0]['generated_result']
|
269 |
+
return_data = json.loads(return_data.replace("'", '"'), strict=False)
|
270 |
return return_data
|
utilities_database/user_database_widgets.py
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
-
from deta import Deta
|
2 |
import streamlit as st
|
3 |
from datetime import datetime
|
|
|
4 |
from utilities_option_menu.option_menu import option_menu
|
5 |
import utilities_database.user_database_utils as db_utils
|
6 |
from utilities_database.user_database_utils import check_usr_pass
|
7 |
from utilities_cookies.encrypted_cookie_manager import EncryptedCookieManager
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
DETA_USER_TABLE = st.secrets['DETA_USER_SAVE_TEXT_TABLE']
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
user_save_text_table =
|
16 |
st.set_page_config(page_title='GenLexTasksEnter', layout="wide", page_icon=':es:')
|
17 |
|
18 |
login_call = 'Зарегистрироваться'
|
@@ -92,7 +91,7 @@ class LogIn:
|
|
92 |
login_submit_button = st.form_submit_button(label='Войти')
|
93 |
|
94 |
if login_submit_button:
|
95 |
-
authenticate_user_check = check_usr_pass(user_log_in_database=
|
96 |
user_name=user_name,
|
97 |
password=password)
|
98 |
|
@@ -120,12 +119,12 @@ class LogIn:
|
|
120 |
email_sign_up = st.text_input("E-mail *",
|
121 |
placeholder='Введите Ваш e-mail')
|
122 |
valid_email_check = db_utils.check_valid_email(email_sign_up)
|
123 |
-
unique_email_check = db_utils.check_unique_email(user_log_in_database=
|
124 |
email_sign_up=email_sign_up)
|
125 |
|
126 |
user_name_sign_up = st.text_input("Имя пользователя *",
|
127 |
placeholder='Введите имя пользователя (латинские буквы и символы)')
|
128 |
-
unique_user_name_check = db_utils.check_unique_usr(user_log_in_database=
|
129 |
user_name_sign_up=user_name_sign_up)
|
130 |
|
131 |
password_sign_up = st.text_input("Пароль *",
|
@@ -157,7 +156,7 @@ class LogIn:
|
|
157 |
|
158 |
if valid_name_check:
|
159 |
if valid_email_check and unique_email_check and unique_user_name_check:
|
160 |
-
db_utils.register_new_usr(user_log_in_database=
|
161 |
name_sign_up=name_sign_up,
|
162 |
email_sign_up=email_sign_up,
|
163 |
user_name_sign_up=user_name_sign_up,
|
@@ -174,7 +173,7 @@ class LogIn:
|
|
174 |
with st.form("Forgot Password Form"):
|
175 |
email_forgot_passwd = st.text_input("Email", placeholder='Введите Ваш email')
|
176 |
email_exists_check, user_name_forgot_passwd = db_utils.check_email_exists(
|
177 |
-
user_log_in_database=
|
178 |
email_forgot_passwd=email_forgot_passwd)
|
179 |
|
180 |
forgot_passwd_submit_button = st.form_submit_button(label='Получить пароль')
|
@@ -187,7 +186,7 @@ class LogIn:
|
|
187 |
random_password = db_utils.generate_random_passwd()
|
188 |
db_utils.send_passwd_in_email(self.auth_token, user_name_forgot_passwd, email_forgot_passwd,
|
189 |
self.company_name, random_password)
|
190 |
-
db_utils.change_passwd(user_log_in_database=
|
191 |
email_forgot_passwd=email_forgot_passwd,
|
192 |
random_password=random_password)
|
193 |
st.success("Временный пароль выслан Вам на почту!")
|
@@ -215,9 +214,9 @@ class LogIn:
|
|
215 |
|
216 |
if reset_passwd_submit_button:
|
217 |
email_exists_check, user_name_reset_passwd = db_utils.check_email_exists(
|
218 |
-
user_log_in_database=
|
219 |
email_forgot_passwd=email_reset_passwd)
|
220 |
-
current_passwd_check = db_utils.check_current_passwd(user_log_in_database=
|
221 |
email_reset_passwd=email_reset_passwd,
|
222 |
current_passwd=current_passwd)
|
223 |
if not email_exists_check:
|
@@ -230,7 +229,7 @@ class LogIn:
|
|
230 |
st.error("Пароли не совпадают!")
|
231 |
|
232 |
if email_exists_check and current_passwd_check:
|
233 |
-
db_utils.change_passwd(user_log_in_database=
|
234 |
email_forgot_passwd=email_reset_passwd,
|
235 |
random_password=new_passwd)
|
236 |
st.success("Пароль успешно изменен!")
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from datetime import datetime
|
3 |
+
from supabase import create_client, Client
|
4 |
from utilities_option_menu.option_menu import option_menu
|
5 |
import utilities_database.user_database_utils as db_utils
|
6 |
from utilities_database.user_database_utils import check_usr_pass
|
7 |
from utilities_cookies.encrypted_cookie_manager import EncryptedCookieManager
|
8 |
|
9 |
+
DB_URL = st.secrets['SUPABASE_URL']
|
10 |
+
DB_KEY = st.secrets['SUPABASE_KEY']
|
|
|
11 |
|
12 |
+
Client = create_client(DB_URL, DB_KEY)
|
13 |
+
user_login_table = Client.table('UserLogIn')
|
14 |
+
user_save_text_table = Client.table('TaskData')
|
15 |
st.set_page_config(page_title='GenLexTasksEnter', layout="wide", page_icon=':es:')
|
16 |
|
17 |
login_call = 'Зарегистрироваться'
|
|
|
91 |
login_submit_button = st.form_submit_button(label='Войти')
|
92 |
|
93 |
if login_submit_button:
|
94 |
+
authenticate_user_check = check_usr_pass(user_log_in_database=user_login_table,
|
95 |
user_name=user_name,
|
96 |
password=password)
|
97 |
|
|
|
119 |
email_sign_up = st.text_input("E-mail *",
|
120 |
placeholder='Введите Ваш e-mail')
|
121 |
valid_email_check = db_utils.check_valid_email(email_sign_up)
|
122 |
+
unique_email_check = db_utils.check_unique_email(user_log_in_database=user_login_table,
|
123 |
email_sign_up=email_sign_up)
|
124 |
|
125 |
user_name_sign_up = st.text_input("Имя пользователя *",
|
126 |
placeholder='Введите имя пользователя (латинские буквы и символы)')
|
127 |
+
unique_user_name_check = db_utils.check_unique_usr(user_log_in_database=user_login_table,
|
128 |
user_name_sign_up=user_name_sign_up)
|
129 |
|
130 |
password_sign_up = st.text_input("Пароль *",
|
|
|
156 |
|
157 |
if valid_name_check:
|
158 |
if valid_email_check and unique_email_check and unique_user_name_check:
|
159 |
+
db_utils.register_new_usr(user_log_in_database=user_login_table,
|
160 |
name_sign_up=name_sign_up,
|
161 |
email_sign_up=email_sign_up,
|
162 |
user_name_sign_up=user_name_sign_up,
|
|
|
173 |
with st.form("Forgot Password Form"):
|
174 |
email_forgot_passwd = st.text_input("Email", placeholder='Введите Ваш email')
|
175 |
email_exists_check, user_name_forgot_passwd = db_utils.check_email_exists(
|
176 |
+
user_log_in_database=user_login_table,
|
177 |
email_forgot_passwd=email_forgot_passwd)
|
178 |
|
179 |
forgot_passwd_submit_button = st.form_submit_button(label='Получить пароль')
|
|
|
186 |
random_password = db_utils.generate_random_passwd()
|
187 |
db_utils.send_passwd_in_email(self.auth_token, user_name_forgot_passwd, email_forgot_passwd,
|
188 |
self.company_name, random_password)
|
189 |
+
db_utils.change_passwd(user_log_in_database=user_login_table,
|
190 |
email_forgot_passwd=email_forgot_passwd,
|
191 |
random_password=random_password)
|
192 |
st.success("Временный пароль выслан Вам на почту!")
|
|
|
214 |
|
215 |
if reset_passwd_submit_button:
|
216 |
email_exists_check, user_name_reset_passwd = db_utils.check_email_exists(
|
217 |
+
user_log_in_database=user_login_table,
|
218 |
email_forgot_passwd=email_reset_passwd)
|
219 |
+
current_passwd_check = db_utils.check_current_passwd(user_log_in_database=user_login_table,
|
220 |
email_reset_passwd=email_reset_passwd,
|
221 |
current_passwd=current_passwd)
|
222 |
if not email_exists_check:
|
|
|
229 |
st.error("Пароли не совпадают!")
|
230 |
|
231 |
if email_exists_check and current_passwd_check:
|
232 |
+
db_utils.change_passwd(user_log_in_database=user_login_table,
|
233 |
email_forgot_passwd=email_reset_passwd,
|
234 |
random_password=new_passwd)
|
235 |
st.success("Пароль успешно изменен!")
|
utilities_language_general/__pycache__/esp_constants.cpython-310.pyc
CHANGED
Binary files a/utilities_language_general/__pycache__/esp_constants.cpython-310.pyc and b/utilities_language_general/__pycache__/esp_constants.cpython-310.pyc differ
|
|
utilities_language_general/__pycache__/esp_utils.cpython-310.pyc
CHANGED
Binary files a/utilities_language_general/__pycache__/esp_utils.cpython-310.pyc and b/utilities_language_general/__pycache__/esp_utils.cpython-310.pyc differ
|
|
utilities_language_general/__pycache__/morphology.cpython-310.pyc
CHANGED
Binary files a/utilities_language_general/__pycache__/morphology.cpython-310.pyc and b/utilities_language_general/__pycache__/morphology.cpython-310.pyc differ
|
|
utilities_language_w2v/__pycache__/esp_main_workflow_w2v.cpython-310.pyc
ADDED
Binary file (7.91 kB). View file
|
|
utilities_language_w2v/__pycache__/esp_sentence_w2v.cpython-310.pyc
ADDED
Binary file (9 kB). View file
|
|
utilities_option_menu/__pycache__/option_menu.cpython-310.pyc
CHANGED
Binary files a/utilities_option_menu/__pycache__/option_menu.cpython-310.pyc and b/utilities_option_menu/__pycache__/option_menu.cpython-310.pyc differ
|
|
utilities_ui/__pycache__/custom_download_button.cpython-310.pyc
CHANGED
Binary files a/utilities_ui/__pycache__/custom_download_button.cpython-310.pyc and b/utilities_ui/__pycache__/custom_download_button.cpython-310.pyc differ
|
|
Вход.py
CHANGED
@@ -16,17 +16,19 @@ __login__obj = LogIn(auth_token=st.secrets['COURIER_AUTH_TOKEN'],
|
|
16 |
hide_footer_bool=False,
|
17 |
lottie_url='https://assets2.lottiefiles.com/packages/lf20_jcikwtux.json')
|
18 |
LOGGED_IN = __login__obj.build_login_ui()
|
19 |
-
st.session_state['-LOGGED_IN-'] =
|
20 |
-
st.session_state['-LOGGED_IN_BOOL-'] = True
|
21 |
-
st.session_state['-USER_NAME-'] = '-PUBLIC_USER-'
|
22 |
# Check for username in cookies
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
if LOGGED_IN:
|
30 |
st.session_state['-LOGGED_IN_BOOL-'] = True
|
31 |
-
# st.session_state['-USER_NAME-'] =
|
32 |
st.success('Можете переходить к следующим вкладкам!')
|
|
|
|
|
|
|
|
|
|
|
|
16 |
hide_footer_bool=False,
|
17 |
lottie_url='https://assets2.lottiefiles.com/packages/lf20_jcikwtux.json')
|
18 |
LOGGED_IN = __login__obj.build_login_ui()
|
19 |
+
st.session_state['-LOGGED_IN-'] = False
|
|
|
|
|
20 |
# Check for username in cookies
|
21 |
+
if '-USER_NAME-' not in st.session_state:
|
22 |
+
if __login__obj.cookies.get('__streamlit_login_signup_ui_username__'):
|
23 |
+
if not is_valid_uuid(__login__obj.cookies['__streamlit_login_signup_ui_username__']):
|
24 |
+
st.session_state['-USER_NAME-'] = __login__obj.cookies['__streamlit_login_signup_ui_username__']
|
25 |
+
st.session_state['-LOGGED_IN_BOOL-'] = True
|
26 |
|
27 |
if LOGGED_IN:
|
28 |
st.session_state['-LOGGED_IN_BOOL-'] = True
|
|
|
29 |
st.success('Можете переходить к следующим вкладкам!')
|
30 |
+
|
31 |
+
# st.markdown('*Автор-разработчик: А.В.Белый, кафедра математической лингвистики, филологический факультет СПбГУ,'
|
32 |
+
# ' 4 курс, бакалавриат, "Прикладная, компьютерная и математическая лингвистика (английский язык)"*'
|
33 |
+
# '\n\n*Научный руководитель: канд. филол. наук, доц. О.А.Митрофанова*')
|
34 |
+
# st.markdown('*E-mail: st087202@student.spbu.ru*')
|