mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 04:36:31 +08:00
fix: resolve DetachedInstanceError on Google OAuth login
When account_integrates has no record, the email fallback path used
sessionmaker(db.engine).begin() which auto-commits on exit, expiring
all attributes on the Account object. Subsequent access to account.id
in get_join_tenants raises DetachedInstanceError.
Remove the independent session wrapper and let
get_account_by_email_with_case_fallback use db.session (request-scoped)
so the returned Account stays attached.
Cherry-picked from bcd738d2e6 on main (#34904).
Made-with: Cursor
This commit is contained in:
parent
1a9a1e821f
commit
a4cb47d6cd
@ -4,7 +4,6 @@ import urllib.parse
|
||||
import httpx
|
||||
from flask import current_app, redirect, request
|
||||
from flask_restx import Resource
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from werkzeug.exceptions import Unauthorized
|
||||
|
||||
from configs import dify_config
|
||||
@ -180,8 +179,7 @@ def _get_account_by_openid_or_email(provider: str, user_info: OAuthUserInfo) ->
|
||||
account: Account | None = Account.get_by_openid(provider, user_info.id)
|
||||
|
||||
if not account:
|
||||
with sessionmaker(db.engine).begin() as session:
|
||||
account = AccountService.get_account_by_email_with_case_fallback(user_info.email, session=session)
|
||||
account = AccountService.get_account_by_email_with_case_fallback(user_info.email)
|
||||
|
||||
return account
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user