Ludovicollin commited on
Commit
3587aad
·
verified ·
1 Parent(s): 19efe10

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -0
main.py CHANGED
@@ -26,6 +26,17 @@ from chainlit import user_session
26
  from offres_emploi import Api
27
  from offres_emploi.utils import dt_to_str_iso
28
  import datetime
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  @cl.author_rename
31
  def rename(orig_author: str):
 
26
  from offres_emploi import Api
27
  from offres_emploi.utils import dt_to_str_iso
28
  import datetime
29
+ from typing import Optional
30
+ import bcrypt
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
+ if resultLogAdmin and resultPwdAdmin:
37
+ return cl.User(
38
+ identifier="Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}
39
+ )
40
 
41
  @cl.author_rename
42
  def rename(orig_author: str):