mgbam commited on
Commit
86a454c
·
verified ·
1 Parent(s): 5fb2d40

Update services/auth.py

Browse files
Files changed (1) hide show
  1. services/auth.py +3 -4
services/auth.py CHANGED
@@ -4,18 +4,18 @@ from config.settings import settings
4
  from repositories.user_repo import UserRepo
5
  from models.db import init_db
6
 
7
- # Ensure the DB tables exist before we fetch users
8
  init_db()
9
 
10
- # Instantiate your user repository
11
  user_repo = UserRepo(settings.database_url)
12
 
13
  def init_auth():
14
  users = user_repo.get_all_users()
15
- creds = {
16
  u.username: {"name": u.full_name, "password": u.hashed_password}
17
  for u in users
18
  }
 
19
  return Authenticate(
20
  credentials=creds,
21
  cookie_name="quantum_healthcare_auth",
@@ -23,7 +23,6 @@ def init_auth():
23
  cookie_expiry_days=1,
24
  )
25
 
26
- # Create the authenticator at import time
27
  authenticator = init_auth()
28
 
29
  def require_login():
 
4
  from repositories.user_repo import UserRepo
5
  from models.db import init_db
6
 
7
+ # Create tables if they don't exist
8
  init_db()
9
 
 
10
  user_repo = UserRepo(settings.database_url)
11
 
12
  def init_auth():
13
  users = user_repo.get_all_users()
14
+ user_map = {
15
  u.username: {"name": u.full_name, "password": u.hashed_password}
16
  for u in users
17
  }
18
+ creds = {"usernames": user_map}
19
  return Authenticate(
20
  credentials=creds,
21
  cookie_name="quantum_healthcare_auth",
 
23
  cookie_expiry_days=1,
24
  )
25
 
 
26
  authenticator = init_auth()
27
 
28
  def require_login():