fix: social login providers now work from DB config without restart
- Extract all OAuth registration into _setup_social_providers() with a _register_oauth_client() helper that clears the authlib _clients cache so credentials can change without a restart - Add refresh_social_providers() public function called after every settings reload (lifespan startup + settings_sync live reload) - Fix connections page linked status to use _get_effective() (DB-aware) instead of the stale startup-time SOCIAL_PROVIDERS dict - Fix oauth_configured template variable similarly - Add tests: DB-driven linked status, stale-provider clearing, register_oauth_client cache-clear, refresh function coverage Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/ef15910f-fd25-469a-814b-9e1fb40659c9
This commit is contained in:
+12
@@ -189,6 +189,18 @@ async def lifespan(app: FastAPI):
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
# Re-register OAuth / social-login providers now that DB settings are
|
||||
# loaded. auth.py runs its initial registration at import time (before
|
||||
# the lifespan runs), so providers that are only configured in the
|
||||
# database would not be registered yet. Calling refresh here ensures
|
||||
# they are active immediately on startup without any manual restart.
|
||||
try:
|
||||
from app.auth import refresh_social_providers
|
||||
|
||||
refresh_social_providers()
|
||||
except Exception as e:
|
||||
logging.warning(f"Could not refresh social login providers on startup: {e}")
|
||||
|
||||
# Initialize Sentry after DB settings are loaded so that values configured
|
||||
# via the database UI (e.g. SENTRY_DSN) are respected in addition to env vars.
|
||||
init_sentry()
|
||||
|
||||
Reference in New Issue
Block a user