Ludovicollin commited on
Commit
efc4534
·
verified ·
1 Parent(s): eddc84f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -3
main.py CHANGED
@@ -34,11 +34,11 @@ def auth_callback(username: str, password: str):
34
  #resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_PASSWD'].encode('utf-8'), bcrypt.gensalt()))
35
  auth = []
36
  auth.append(os.environ['CHAINLIT_AUTH_LOGIN'])
37
- ident = next(d['ident'] for d in auth if d['ident'] == username)
38
- pwd = next(d['pwd'] for d in auth if d['ident'] == username)
39
  resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
40
  resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
41
- resultRole = next(d['role'] for d in auth if d['ident'] == username)
42
  if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
43
  return cl.User(
44
  identifier="🧑‍💼 Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}
 
34
  #resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(os.environ['CHAINLIT_AUTH_PASSWD'].encode('utf-8'), bcrypt.gensalt()))
35
  auth = []
36
  auth.append(os.environ['CHAINLIT_AUTH_LOGIN'])
37
+ ident = next(d['ident'] for d,i in auth if d[i].ident == username)
38
+ pwd = next(d['pwd'] for d,i in auth if d[i].ident == username)
39
  resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
40
  resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
41
+ resultRole = next(d['role'] for d,i in auth if d[i].ident == username)
42
  if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
43
  return cl.User(
44
  identifier="🧑‍💼 Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}