ken_nogi/NodeSrv/apps/lineworks-user-auth/src/adminView.js
Kenichiro NOGI ce58cb4be4 初回コミット: dev配下(NodeSrv/Pleasanter等)をGitea管理下に統合
GitHub(nextgroup2706/ken_nogi)は今後使わず自社Gitea運用に切替え。
NodeSrvは旧リポジトリの履歴を破棄しファイルのみ統合(Dokploy用サービスアカウントは
別途mygit-admin/NodeSrv.gitに履歴あり)。notepmエクスポート(12GB)とPleasanter
インストーラzip(208MB)はサイズが大きいため.gitignoreで除外。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 15:37:06 +09:00

57 lines
2.7 KiB
JavaScript

"use strict";
function escapeHtml(value) {
return String(value ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
}
function renderLoginPage(errorMessage) {
return `<!doctype html>
<html lang="ja"><head><meta charset="utf-8"><title>lineworks-user-auth ログイン</title></head>
<body>
<h1>lineworks-user-auth</h1>
${errorMessage ? `<p style="color:red">${escapeHtml(errorMessage)}</p>` : ""}
<form method="post" action="/auth/login">
<label>Master Key: <input type="password" name="masterKey" /></label>
<button type="submit">ログイン</button>
</form>
</body></html>`;
}
function renderDashboardPage({ records, message }) {
const rows = records
.map(
(r) => `<tr><td>${escapeHtml(r.key)}</td><td>${escapeHtml(r.account)}</td><td>${escapeHtml(r.status)}</td><td>${escapeHtml(r.expiresAt)}</td>
<td><form method="get" action="/auth/start" style="display:inline"><input type="hidden" name="account" value="${escapeHtml(r.account)}" /><button type="submit">再認可</button></form></td></tr>`
)
.join("");
return `<!doctype html>
<html lang="ja"><head><meta charset="utf-8"><title>lineworks-user-auth</title></head>
<body>
<h1>LINEWORKS User Account 連携キー一覧</h1>
${message ? `<p>${escapeHtml(message)}</p>` : ""}
<table border="1"><thead><tr><th>連携キー</th><th>対象アカウント</th><th>ステータス</th><th>再認可目安(90日)</th><th></th></tr></thead>
<tbody>${rows}</tbody></table>
<h2>新規登録</h2>
<form method="get" action="/auth/start">
<label>対象LINEWORKSアカウント: <input type="text" name="account" required /></label>
<button type="submit">LINEWORKSでログインして登録</button>
</form>
<p style="color:#666">連携キーはアカウントの@より前の部分から自動生成されます。</p>
<form method="post" action="/auth/temp-key" style="display:inline"><button type="submit">一時アクセスキー発行(60分・Master Key不要で共有可)</button></form>
<form method="post" action="/auth/logout" style="display:inline"><button type="submit">ログアウト</button></form>
</body></html>`;
}
function renderTempKeyPage({ url }) {
return `<!doctype html>
<html lang="ja"><head><meta charset="utf-8"><title>一時アクセスキー発行</title></head>
<body>
<h1>一時アクセスキーを発行しました</h1>
<p>有効期限60分。このURLを共有してください(Master Keyは含まれません):</p>
<p><code>${escapeHtml(url)}</code></p>
<p><a href="/auth">ダッシュボードへ戻る</a></p>
</body></html>`;
}
module.exports = { renderLoginPage, renderDashboardPage, renderTempKeyPage };