admin08077 commited on
Commit
7204599
·
verified ·
1 Parent(s): 4beab32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -259,29 +259,29 @@ def process_ai(input_text):
259
 
260
  # Fetch users from the database
261
  users = session.query(User).all()
262
- usernames = [user.username for user in users]
263
- names = [user.username for user in users]
264
- passwords = [user.password for user in users]
265
-
266
- # Initialize Authenticator
267
- if users:
268
- authenticator = stauth.Authenticate(
269
- names,
270
- usernames,
271
- passwords,
272
- 'citibank_demo_business_inc_ai_crypto', # cookie_name
273
- 'abcdef', # key
274
- 1 # cookie_expiry_days
275
- )
276
- else:
277
- authenticator = stauth.Authenticate(
278
- [],
279
- [],
280
- [],
281
- 'citibank_demo_business_inc_ai_crypto', # cookie_name
282
- 'abcdef', # key
283
- 1 # cookie_expiry_days
284
- )
285
 
286
  name, authentication_status, username = authenticator.login('Login', 'main')
287
 
 
259
 
260
  # Fetch users from the database
261
  users = session.query(User).all()
262
+
263
+ # Build the credentials dictionary
264
+ credentials = {
265
+ "usernames": {
266
+ user.username: {
267
+ "name": user.username, # Customize if you have a separate name field
268
+ "password": user.password # This should be the hashed password
269
+ }
270
+ for user in users
271
+ }
272
+ }
273
+
274
+ # If no users are present, ensure 'usernames' is an empty dictionary
275
+ if not users:
276
+ credentials = {"usernames": {}}
277
+
278
+ # Initialize Authenticator with keyword arguments
279
+ authenticator = stauth.Authenticate(
280
+ credentials,
281
+ 'citibank_demo_business_inc_ai_crypto', # cookie_name
282
+ 'abcdef', # key
283
+ cookie_expiry_days=1 # cookie_expiry_days
284
+ )
285
 
286
  name, authentication_status, username = authenticator.login('Login', 'main')
287