From 12f1d455b93abfa230b00a5d0f323a91dfb3ff6a Mon Sep 17 00:00:00 2001 From: king Date: Fri, 16 Oct 2026 16:59:14 +0900 Subject: [PATCH] =?UTF-8?q?fix(inout):=20=EB=A9=94=EC=9D=BC=20=EC=B0=BD=20?= =?UTF-8?q?=E2=80=94=20=EC=97=B0=EA=B2=B0=20=EC=A0=84=20=EC=95=84=EB=9E=98?= =?UTF-8?q?=20=EC=A4=84=20=EC=88=A8=EA=B9=80,=20redirect=5Furi=5Fmismatch?= =?UTF-8?q?=20=EB=8C=80=EB=B9=84=20=EB=93=B1=EB=A1=9D=ED=95=A0=20=EC=A3=BC?= =?UTF-8?q?=EC=86=8C=20=EC=95=88=EB=82=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .io-dlg-footbar 의 display:flex 가 hidden 속성을 덮어써 연결 전에도 [메일 발송]·[연결 끊기]가 보이던 문제 → .io/.io-dlg/.io-viewer 안의 [hidden] 은 늘 숨김. - 구글이 redirect_uri_mismatch 로 막으면 ERP 로 돌아오지 않으므로, 연결 안내에 구글 클라우드 "승인된 리디렉션 URI"에 넣을 정확한 주소(callback_url)를 미리 보여 준다. Co-Authored-By: Claude Opus 5.5 --- app/modules/inout/router.py | 7 +++++++ app/modules/inout/templates/inout/index.html | 4 ++-- app/modules/inout/templates/inout/order_detail.html | 4 ++-- app/modules/inout/templates/inout/order_form.html | 4 ++-- app/modules/inout/templates/inout/pending.html | 4 ++-- app/static/inout.css | 4 ++++ app/static/inout.js | 6 +++++- tests/test_inout_web.py | 1 + 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/modules/inout/router.py b/app/modules/inout/router.py index 1e209c0..7e816bd 100644 --- a/app/modules/inout/router.py +++ b/app/modules/inout/router.py @@ -491,6 +491,12 @@ def photo_view(request: Request, photo_id: int) -> Response: # ──────────────────────────────────────────────────────────── # 발주 메일 — 발주 담당 본인 Gmail(003). 연결은 사람마다 한 번, 보내기는 [메일 발송]을 눌렀을 때만. # ──────────────────────────────────────────────────────────── +def _callback_url(request: Request) -> str: + from app.main import public_url_for # noqa: WPS433 + + return public_url_for(request, "inout_gmail_callback") + + def _safe_next(nxt: Any) -> str: s = str(nxt or "") return s if s.startswith("/inout/") and "//" not in s and "\\" not in s else "/inout/" @@ -584,6 +590,7 @@ def mail_preview(request: Request, order_id: int) -> JSONResponse: return JSONResponse({ "connected": tok is not None, "configured": gmail.configured(), "connect_url": f"/inout/gmail/connect?{urlencode({'next': f'/inout/orders/{order_id}?mail=1'})}", + "callback_url": _callback_url(request), # 구글 클라우드 승인된 리디렉션 URI 에 등록해야 하는 주소(안내용) "from": user.get("email", ""), "to": order.get("factory_email") or "", "factory": order["factory_name"], "subject": mail["subject"], "html": mail["html"], "sent": [{"at": m["sent_at"].strftime("%Y-%m-%d %H:%M"), "by": m["sent_by"], "to": m["to_addrs"]} for m in order["mails"]], diff --git a/app/modules/inout/templates/inout/index.html b/app/modules/inout/templates/inout/index.html index 6451d24..44a0e1a 100644 --- a/app/modules/inout/templates/inout/index.html +++ b/app/modules/inout/templates/inout/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import status_badge, progress, due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -58,4 +58,4 @@
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 82184e7..d966a13 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import status_badge, progress, due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} @@ -200,4 +200,4 @@ {% endif %} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_form.html b/app/modules/inout/templates/inout/order_form.html index 6459805..670b5fd 100644 --- a/app/modules/inout/templates/inout/order_form.html +++ b/app/modules/inout/templates/inout/order_form.html @@ -1,5 +1,5 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -76,4 +76,4 @@
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/pending.html b/app/modules/inout/templates/inout/pending.html index 7a7e5cf..32cbeb4 100644 --- a/app/modules/inout/templates/inout/pending.html +++ b/app/modules/inout/templates/inout/pending.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -88,4 +88,4 @@ {% endif %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/static/inout.css b/app/static/inout.css index 5ff462e..e6da876 100644 --- a/app/static/inout.css +++ b/app/static/inout.css @@ -112,6 +112,8 @@ · .erp-input 은 min-width 240px + content-box 라 좁은 칸에서 옆 칸을 덮는다 → 이 모듈 안에서는 테두리 기준·최소폭 없음 · .erp-table-wrap 은 카드 모양(그림자·둥근 모서리)이라 카드 안에 넣으면 상자가 겹쳐 보인다 → 카드 안에서는 평평하게 */ .io *, .io *::before, .io *::after, .io-dlg *, .io-dlg *::before, .io-dlg *::after { box-sizing: border-box; } +/* hidden 속성은 늘 숨김 — display 를 준 요소(예: 메일 창 아래 줄 flex)가 hidden 을 덮어써 보이던 문제(2026-10-16) */ +.io [hidden], .io-dlg [hidden], .io-viewer [hidden] { display: none !important; } .io .erp-input { min-width: 0; } .io .erp-card-block .erp-table-wrap { border-radius: 0; box-shadow: none; background: transparent; } @@ -193,6 +195,8 @@ .io-mail-preview { width: 100%; height: 380px; border: 1px solid var(--color-subtle-ash); border-radius: 8px; background: #fff; } .io-mail-connect { padding: 8px 2px 4px; font-size: 13.5px; line-height: 1.7; } .io-mail-connect .erp-btn { margin-top: 6px; } +.io-mail-admin { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--color-ghost-gray); font-size: 12px; color: #3d3f42; } +.io-mail-admin code { display: inline-block; margin-top: 4px; padding: 2px 6px; border-radius: 4px; background: #fff; border: 1px solid var(--color-subtle-ash); font-size: 12px; user-select: all; word-break: break-all; } .io-hint { margin: -4px 0 12px; font-size: 12.5px; color: #9a5b00; } .io-dlg-footbar { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--color-subtle-ash); background: #fafbfc; } .io-link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--color-midtone-gray); text-decoration: underline; cursor: pointer; } diff --git a/app/static/inout.js b/app/static/inout.js index e3f9426..8417681 100644 --- a/app/static/inout.js +++ b/app/static/inout.js @@ -471,7 +471,11 @@ "

발주 메일은 내 Gmail(" + esc(data.from) + ")로 보냅니다. 처음 한 번만 Gmail 연결이 필요합니다.

" + "

구글 화면에서 같은 계정을 고르고 '메일 보내기' 권한을 허락하세요. 보내기 권한만 받으며, 메일함은 읽지 않습니다.

" + (data.configured ? "" : '

서버 설정(APP_ENCRYPTION_KEY·구글 OAuth)이 없어 연결할 수 없습니다 — 관리자에게 알려 주세요.

') + - 'Gmail 연결'; + 'Gmail 연결' + + // 구글이 redirect_uri_mismatch 로 막으면 ERP 로 돌아오지 않는다 — 등록할 주소를 미리 보여 준다 + '
구글 화면에 400 오류: redirect_uri_mismatch 가 나오면, 관리자가 구글 클라우드 → API 및 서비스 → 사용자 인증 정보 → ' + + '로그인용 OAuth 클라이언트 → 승인된 리디렉션 URI에 아래 주소를 추가해야 합니다(Gmail API 사용·gmail.send 범위도 함께).
' + + '' + esc(data.callback_url) + '
'; return; } foot.hidden = false; diff --git a/tests/test_inout_web.py b/tests/test_inout_web.py index ccfc9c5..80474ef 100644 --- a/tests/test_inout_web.py +++ b/tests/test_inout_web.py @@ -241,6 +241,7 @@ def body(c): who["u"] = buyer pv = c.get("/inout/orders/%d/mail" % oid3).json() assert pv["connected"] is False and pv["connect_url"].startswith("/inout/gmail/connect?next=") + assert pv["callback_url"].endswith("/inout/gmail/callback") # 구글에 등록할 주소 안내 assert pv["to"] == "factory-%s@x.com" % tag and pv["subject"].startswith("[발주] ") and "가 단품" in pv["html"] r = c.post("/inout/orders/%d/mail" % oid3, json={"to": pv["to"]}) assert r.status_code == 409 and r.json()["reconnect"] is True # 연결 전엔 못 보냄