-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
37 lines (30 loc) · 1.22 KB
/
Copy pathtest.py
File metadata and controls
37 lines (30 loc) · 1.22 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
from pymongo import MongoClient
from Connection import Connection
import re
cluster = MongoClient(
"mongodb+srv://Logan:lolo123@cluster0.igyjs.mongodb.net/ecole?retryWrites=true&w=majority")
db = cluster.testdb
collection = db.testcollection
roles = db.roles
class ManageRole(Connection):
def __init__(self, username, password=''):
Connection.__init__(self, username, password)
def determine_role_user(self, commande):
test = {}
self.commande = commande
self.role_user = self.get_user_data_from_db["role"]
for j in self.role_user:
all_roles = roles.find({"Role": j})
if all_roles:
print("yes")
for i in all_roles:
for key, values in i.items():
test[key] = values
return test
# if i in self.role_user:
# if commande == i:
# return f"L'utilisateur peut utiliser la commande {commande}"
# return f"La commande {commande} n'existe pas"
# return f"L'utilisateur ne peut pas utiliser la commande {commande}"
a = ManageRole("Verum")
print(a.determine_role_user("METE"))