Ludovicollin commited on
Commit
23d8835
·
verified ·
1 Parent(s): 8710b86

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -32,8 +32,10 @@ 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
- resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(next(d['ident'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username).encode('utf-8'), bcrypt.gensalt()))
36
- resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(next(d['pwd'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username).encode('utf-8'), bcrypt.gensalt()))
 
 
37
  resultRole = next(d['role'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username)
38
  if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
39
  return cl.User(
 
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
+ ident = next(d['ident'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username)
36
+ pwd = next(d['pwd'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username)
37
+ resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
38
+ resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
39
  resultRole = next(d['role'] for d in os.environ['CHAINLIT_AUTH_LOGIN'] if d['ident'] == username)
40
  if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
41
  return cl.User(