Skip to content

Commit 040b409

Browse files
Fix UnboundLocalError in render_login() caused by redundant oauth_bb import
The function was attempting to import oauth_bb locally inside the function body, which caused Python to treat oauth_bb as a local variable throughout the entire function scope. This resulted in an UnboundLocalError when trying to access oauth_bb.oauth_check on line 1956, before the import statement on line 1965. The oauth_bb module is already imported at the module level (lines 69-90) with proper fallback handling via MockOAuth when OAuth is unavailable. The local import inside the function is redundant and breaks name resolution. Solution: Remove the redundant `from . import oauth_bb` import from inside the render_login() function. The module-level import is sufficient for all uses within the function. Fixes: 500 Internal Server Error on login page Caused by: Commits 29de7bd (import refactoring) and 7c49f5c (incomplete fix) Related issues: - Commit 29de7bd: "Fix language selection missing when OAuth/OIDC enabled" - Commit 7c49f5c: "Fix NameError: oauth_check not defined in render_login()"
1 parent 987e700 commit 040b409

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

CONTRIBUTORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Copyright (C) 2024-2026 Calibre-Web Automated contributors
312312
- zhiyue (1 commits)
313313
# Fork Contributors (crocodilestick/calibre-web-automated)
314314

315-
- crocodilestick (896 commits)
315+
- crocodilestick (899 commits)
316316
- jmarmstrong1207 (73 commits)
317317
- demitrix (30 commits)
318318
- sirwolfgang (29 commits)
@@ -383,6 +383,7 @@ Copyright (C) 2024-2026 Calibre-Web Automated contributors
383383
- marauder37 (1 commits)
384384
- Marodeur80 (anon) (1 commits)
385385
- Matteo Benaroyo (anon) (1 commits)
386+
- mehalter (1 commits)
386387
- morpheus65535 (1 commits)
387388
- n00b42 (1 commits)
388389
- Nementon (1 commits)

cps/web.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,6 @@ def render_login(username="", password=""):
19601960
if feature_support['oauth']:
19611961
try:
19621962
# oauth_bb is already imported at module level, access oauthblueprints from it
1963-
from . import oauth_bb
19641963
# oauthblueprints[2] is the generic OIDC provider (index 0=github, 1=google, 2=generic)
19651964
if hasattr(oauth_bb, 'oauthblueprints') and len(oauth_bb.oauthblueprints) > 2:
19661965
generic_login_button = oauth_bb.oauthblueprints[2].get('login_button') or 'OpenID Connect'

0 commit comments

Comments
 (0)