-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbOperation.py
41 lines (28 loc) · 1.1 KB
/
dbOperation.py
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
from os import getenv
from db import Mongo
def userExists(userName:str, client:Mongo):
# Checking if that user is existed in User Section
if client.isDocExists({'username' : f'{userName.strip()}'}, getenv('USER_COLLECTION')):
return True, False, False
# Checking if that user is existed in Pending Section
if client.isDocExists({'username' : f'{userName.strip()}'}, getenv('PENDING_USER_COLLECTION')):
return True, True, False
# Checking if that user is existed in Manager Section
if is_manager(userName, client):
return True, False, True
return False, None, None
def is_manager(userName:str, client:Mongo):
if client.isDocExists({'username' : f'{userName.strip()}'}, getenv('MANAGER_COLLECTION')):
return True
else:
return False
def isPassCorrect(userName:str, password:str, client:Mongo):
block = client.get_doc({
"username" : userName
}, getenv('USER_COLLECTION'))
if block == None:
return False
if block.get('password') == password:
return True
else:
return False