Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -27,12 +27,14 @@ from offres_emploi import Api
|
|
| 27 |
from offres_emploi.utils import dt_to_str_iso
|
| 28 |
import datetime
|
| 29 |
import bcrypt
|
|
|
|
| 30 |
|
| 31 |
@cl.password_auth_callback
|
| 32 |
def auth_callback(username: str, password: str):
|
| 33 |
#resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_LOGIN'].encode('utf-8'), bcrypt.gensalt()))
|
| 34 |
#resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_PASSWD'].encode('utf-8'), bcrypt.gensalt()))
|
| 35 |
-
|
|
|
|
| 36 |
ident = next(d['ident'] for d in auth if d['ident'] == username)
|
| 37 |
pwd = next(d['pwd'] for d in auth if d['ident'] == username)
|
| 38 |
resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
|
|
|
|
| 27 |
from offres_emploi.utils import dt_to_str_iso
|
| 28 |
import datetime
|
| 29 |
import bcrypt
|
| 30 |
+
import json
|
| 31 |
|
| 32 |
@cl.password_auth_callback
|
| 33 |
def auth_callback(username: str, password: str):
|
| 34 |
#resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_LOGIN'].encode('utf-8'), bcrypt.gensalt()))
|
| 35 |
#resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_PASSWD'].encode('utf-8'), bcrypt.gensalt()))
|
| 36 |
+
arrayAuth = "[" + os.environ['CHAINLIT_AUTH_LOGIN'] + "]"
|
| 37 |
+
auth = json.loads(arrayAuth)
|
| 38 |
ident = next(d['ident'] for d in auth if d['ident'] == username)
|
| 39 |
pwd = next(d['pwd'] for d in auth if d['ident'] == username)
|
| 40 |
resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
|