fix(공통): 로그인 후 보던 화면으로 복귀 + 깨진 users.json 덮어쓰기 방지

- app/store.py login_redirect(): 로그인 전 화면 주소를 /login?next= 로 넘긴다(GET 만 —
  폼 POST 주소로 돌아가면 405). 경비·쿠팡·휴가·말레이시아·배송·카페24·실적 11곳이
  next 없이 /login 으로 보내던 것과 프로젝트·입출고·안내문 발송의 복사본 4벌을 이 함수로.
- UserStore._read: JSONDecodeError 를 빈 목록으로 삼키지 않는다 — 다음 로그인이 전체
  사용자·권한을 그 한 명으로 덮어쓰던 것을 막는다.
- tests/test_login_redirect.py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 10:45:58 +09:00
parent c9b4fa36fe
commit 007a16eb9c
12 changed files with 108 additions and 40 deletions
+2 -5
View File
@@ -63,15 +63,12 @@ def _db(request: Request) -> Any:
def _page(request: Request) -> Any:
"""화면 공통 — (st, user) 또는 응답(로그인·권한·설정 필요)."""
from urllib.parse import quote # noqa: WPS433
from app.main import build_erp_nav, get_current_user_record, render_template # noqa: WPS433
from app.store import has_module, is_admin # noqa: WPS433
from app.store import has_module, is_admin, login_redirect # noqa: WPS433
user = get_current_user_record(request)
if user is None:
here = str(request.url.path) + ("?" + request.url.query if request.url.query else "")
return RedirectResponse(url="/login?next=" + quote(here, safe=""), status_code=303)
return login_redirect(request)
if not has_module(user, "outreach"):
return render_template(request, "denied.html", {"reason": "안내문 발송 모듈 접근 권한이 없습니다.",
"is_admin": is_admin(user)}, status_code=403)