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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -5
main.py CHANGED
@@ -32,13 +32,12 @@ import bcrypt
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
- 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"}
 
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
+ auth = os.environ['CHAINLIT_AUTH_LOGIN']
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()))
39
  resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
40
+ resultRole = next(d['role'] for d in auth if d['ident'] == username)
41
  if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
42
  return cl.User(
43
  identifier="🧑‍💼 Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}