Major Features: - ✅ Multi-tenant architecture (tenant isolation) - ✅ Employee CRUD with lifecycle management (onboarding/offboarding) - ✅ Department tree structure with email domain management - ✅ Company info management (single-record editing) - ✅ System functions CRUD (permission management) - ✅ Email account management (multi-account per employee) - ✅ Keycloak SSO integration (auth.lab.taipei) - ✅ Redis session storage (10.1.0.254:6379) - Solves Cookie 4KB limitation - Cross-system session sharing - Sliding expiration (8 hours) - Automatic token refresh Technical Stack: Backend: - FastAPI + SQLAlchemy - PostgreSQL 16 (10.1.0.20:5433) - Keycloak Admin API integration - Docker Mailserver integration (SSH) - Alembic migrations Frontend: - Next.js 14 (App Router) - NextAuth 4 with Keycloak Provider - Redis session storage (ioredis) - Tailwind CSS Infrastructure: - Redis 7 (10.1.0.254:6379) - Session + Cache - Keycloak 26.1.0 (auth.lab.taipei) - Docker Mailserver (10.1.0.254) Architecture Highlights: - Session管理由 Keycloak + Redis 統一控制 - 支援多系統 (HR/WebMail/Calendar/Drive/Office) 共享 session - Token 自動刷新,異質服務整合 - 未來可無縫遷移到雲端 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
107 lines
3.7 KiB
HTML
107 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Debug Session & Menu API</title>
|
|
<style>
|
|
body { font-family: monospace; padding: 20px; }
|
|
pre { background: #f5f5f5; padding: 10px; border: 1px solid #ddd; }
|
|
.section { margin-bottom: 30px; }
|
|
button { padding: 10px 20px; margin: 5px; cursor: pointer; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>HR Portal Debug Tool</h1>
|
|
|
|
<div class="section">
|
|
<h2>1. Test Menu API (is_sysmana=true)</h2>
|
|
<button onclick="testMenuAPI(true)">Test is_sysmana=true</button>
|
|
<button onclick="testMenuAPI(false)">Test is_sysmana=false</button>
|
|
<pre id="menu-result">點擊按鈕測試...</pre>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2>2. Check Current Tenant Info</h2>
|
|
<button onclick="checkTenant()">Get Current Tenant</button>
|
|
<pre id="tenant-result">點擊按鈕測試...</pre>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2>3. Browser Console</h2>
|
|
<p>請開啟瀏覽器 DevTools (F12) 查看 Console 輸出</p>
|
|
</div>
|
|
|
|
<script>
|
|
const API_BASE = 'http://10.1.0.245:10181/api/v1';
|
|
|
|
async function testMenuAPI(isSysmana) {
|
|
const resultElement = document.getElementById('menu-result');
|
|
resultElement.textContent = 'Loading...';
|
|
|
|
try {
|
|
const url = `${API_BASE}/system-functions/menu/tree?is_sysmana=${isSysmana}`;
|
|
console.log('Fetching:', url);
|
|
|
|
const response = await fetch(url, {
|
|
method: 'GET',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
credentials: 'include'
|
|
});
|
|
|
|
console.log('Response status:', response.status);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log('Menu data:', data);
|
|
|
|
resultElement.textContent = `Success! Found ${data.length} items:\n\n` +
|
|
JSON.stringify(data, null, 2);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
resultElement.textContent = `ERROR: ${error.message}`;
|
|
}
|
|
}
|
|
|
|
async function checkTenant() {
|
|
const resultElement = document.getElementById('tenant-result');
|
|
resultElement.textContent = 'Loading...';
|
|
|
|
try {
|
|
const url = `${API_BASE}/tenants/current`;
|
|
console.log('Fetching:', url);
|
|
|
|
const response = await fetch(url, {
|
|
method: 'GET',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
credentials: 'include'
|
|
});
|
|
|
|
console.log('Response status:', response.status);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log('Tenant data:', data);
|
|
|
|
const isSysmana = data.is_sysmana || false;
|
|
|
|
resultElement.textContent =
|
|
`Tenant Info:\n` +
|
|
`- ID: ${data.id}\n` +
|
|
`- Code: ${data.code}\n` +
|
|
`- Name: ${data.name}\n` +
|
|
`- is_sysmana: ${isSysmana}\n\n` +
|
|
`Full data:\n${JSON.stringify(data, null, 2)}`;
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
resultElement.textContent = `ERROR: ${error.message}`;
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|