fix(inout): 메일 창 — 연결 전 아래 줄 숨김, redirect_uri_mismatch 대비 등록할 주소 안내

- .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 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 16:59:14 +09:00
parent 9429485236
commit 12f1d455b9
8 changed files with 25 additions and 9 deletions
+7
View File
@@ -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"]],
+2 -2
View File
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% from "inout/_macros.html" import status_badge, progress, due, n %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016d" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016e" />{% endblock %}
{% block content %}
<section class="io">
@@ -58,4 +58,4 @@
</div>
</section>
{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016c" defer></script>{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016d" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% from "inout/_macros.html" import status_badge, progress, due, n %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016d" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016e" />{% endblock %}
{% block content %}
{% set active = order.status in ('open', 'partial') %}
@@ -200,4 +200,4 @@
{% endif %}
</section>
{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016c" defer></script>{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016d" defer></script>{% endblock %}
@@ -1,5 +1,5 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016d" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016e" />{% endblock %}
{% block content %}
<section class="io">
@@ -76,4 +76,4 @@
</form>
</section>
{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016c" defer></script>{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016d" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% from "inout/_macros.html" import due, n %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016d" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016e" />{% endblock %}
{% block content %}
<section class="io">
@@ -88,4 +88,4 @@
{% endif %}
</section>
{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016c" defer></script>{% endblock %}
{% block scripts %}<script src="/static/inout.js?v=20261016d" defer></script>{% endblock %}
+4
View File
@@ -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; }
+5 -1
View File
@@ -471,7 +471,11 @@
"<p><b>발주 메일은 내 Gmail(" + esc(data.from) + ")로 보냅니다.</b> 처음 한 번만 Gmail 연결이 필요합니다.</p>" +
"<p class=\"erp-muted\">구글 화면에서 <b>같은 계정</b>을 고르고 '메일 보내기' 권한을 허락하세요. 보내기 권한만 받으며, 메일함은 읽지 않습니다.</p>" +
(data.configured ? "" : '<p class="io-error">서버 설정(APP_ENCRYPTION_KEY·구글 OAuth)이 없어 연결할 수 없습니다 — 관리자에게 알려 주세요.</p>') +
'<a class="erp-btn erp-btn-primary" href="' + esc(data.connect_url) + '">Gmail 연결</a></div>';
'<a class="erp-btn erp-btn-primary" href="' + esc(data.connect_url) + '">Gmail 연결</a>' +
// 구글이 redirect_uri_mismatch 로 막으면 ERP 로 돌아오지 않는다 — 등록할 주소를 미리 보여 준다
'<div class="io-mail-admin">구글 화면에 <b>400 오류: redirect_uri_mismatch</b> 가 나오면, 관리자가 구글 클라우드 → API 및 서비스 → 사용자 인증 정보 → ' +
'로그인용 OAuth 클라이언트 → <b>승인된 리디렉션 URI</b>에 아래 주소를 추가해야 합니다(Gmail API 사용·gmail.send 범위도 함께).<br>' +
'<code>' + esc(data.callback_url) + '</code></div></div>';
return;
}
foot.hidden = false;