File tree Expand file tree Collapse file tree 4 files changed +549
-519
lines changed Expand file tree Collapse file tree 4 files changed +549
-519
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ dependencies = [
13
13
" pyjwt<3.0.0,>=2.10.1" ,
14
14
" jinja2<4.0.0,>=3.1.4" ,
15
15
" uvicorn<1.0.0,>=0.32.0" ,
16
- " psycopg2<3.0.0,>=2.9.10" ,
17
16
" pydantic[email]<3.0.0,>=2.9.2" ,
18
17
" python-multipart<1.0.0,>=0.0.17" ,
19
18
" python-dotenv<2.0.0,>=1.0.1" ,
20
19
" resend<3.0.0,>=2.4.0" ,
21
20
" bcrypt<5.0.0,>=4.2.0" ,
22
21
" fastapi<1.0.0,>=0.115.5" ,
23
22
" pillow>=11.0.0" ,
23
+ " psycopg2-binary>=2.9.10" ,
24
24
]
25
25
26
26
[dependency-groups ]
@@ -31,5 +31,5 @@ dev = [
31
31
" notebook<8.0.0,>=7.2.2" ,
32
32
" pytest<9.0.0,>=8.3.3" ,
33
33
" sqlalchemy-schemadisplay<3.0,>=2.0" ,
34
- " mypy>=1.15.0 " ,
34
+ " mypy>=1.18.2 " ,
35
35
]
Original file line number Diff line number Diff line change @@ -375,15 +375,19 @@ async def login(
375
375
376
376
# Process the invitation
377
377
try :
378
- logger .info (f"Processing invitation { invitation .id } for user { account .user .id } during login." )
379
- process_invitation (invitation , account .user , session )
380
- session .commit ()
381
- # Set redirect to the organization page
382
- redirect_url = org_router .url_path_for ("read_organization" , org_id = invitation .organization_id )
383
- logger .info (f"Redirecting user { account .user .id } to organization { invitation .organization_id } after accepting invitation { invitation .id } ." )
378
+ if account .user and account .user .id :
379
+ logger .info (f"Processing invitation { invitation .id } for user { account .user .id } during login." )
380
+ process_invitation (invitation , account .user , session )
381
+ session .commit ()
382
+ # Set redirect to the organization page
383
+ redirect_url = org_router .url_path_for ("read_organization" , org_id = invitation .organization_id )
384
+ logger .info (f"Redirecting user { account .user .id } to organization { invitation .organization_id } after accepting invitation { invitation .id } ." )
385
+ else :
386
+ logger .error ("User has no ID during invitation processing." )
387
+ raise DataIntegrityError (resource = "User ID" )
384
388
except Exception as e :
385
389
logger .error (
386
- f "Error processing invitation { invitation . id } for user { account . user . id } during login: { e } " ,
390
+ "Error processing invitation during login: {e}" ,
387
391
exc_info = True
388
392
)
389
393
session .rollback ()
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def env_vars(monkeypatch):
45
45
46
46
47
47
@pytest .fixture
48
- def engine (env_vars ) -> Engine :
48
+ def engine (env_vars ):
49
49
"""
50
50
Create a new SQLModel engine for the test database.
51
51
Use PostgreSQL for testing to match production environment.
@@ -136,13 +136,13 @@ def test_organization(session: Session) -> Organization:
136
136
session .add (organization )
137
137
session .flush ()
138
138
139
- if organization .id is None :
139
+ if organization .id :
140
+ # Use the utility function to create default roles and assign permissions
141
+ # This function handles the commit internally
142
+ create_default_roles (session , organization .id , check_first = False )
143
+ else :
140
144
pytest .fail ("Failed to get organization ID after flush" )
141
145
142
- # Use the utility function to create default roles and assign permissions
143
- # This function handles the commit internally
144
- create_default_roles (session , organization .id , check_first = False )
145
-
146
146
return organization
147
147
148
148
You can’t perform that action at this time.
0 commit comments