Seth0330 commited on
Commit
796a23b
·
verified ·
1 Parent(s): db4c196

Update backend/app/auth.py

Browse files
Files changed (1) hide show
  1. backend/app/auth.py +8 -7
backend/app/auth.py CHANGED
@@ -8,6 +8,12 @@ from sqlalchemy.orm import Session
8
  from .db import SessionLocal
9
  from .models import User
10
 
 
 
 
 
 
 
11
  # JWT Configuration
12
  SECRET_KEY = os.environ.get("JWT_SECRET_KEY", "your-secret-key-change-in-production")
13
  ALGORITHM = "HS256"
@@ -45,13 +51,8 @@ def verify_token(token: str) -> dict:
45
  )
46
 
47
 
48
- def get_db():
49
- """Database dependency."""
50
- db = SessionLocal()
51
- try:
52
- yield db
53
- finally:
54
- db.close()
55
 
56
 
57
  def get_current_user(
 
8
  from .db import SessionLocal
9
  from .models import User
10
 
11
+ # Import get_db from main to avoid circular dependency
12
+ def _get_db_from_main():
13
+ """Import get_db from main.py to avoid circular dependencies."""
14
+ from .main import get_db
15
+ return get_db
16
+
17
  # JWT Configuration
18
  SECRET_KEY = os.environ.get("JWT_SECRET_KEY", "your-secret-key-change-in-production")
19
  ALGORITHM = "HS256"
 
51
  )
52
 
53
 
54
+ # Note: get_db is defined in main.py to avoid circular imports
55
+ # This function is kept here for backward compatibility but should use the one from main.py
 
 
 
 
 
56
 
57
 
58
  def get_current_user(