Files
QuantEngineByItz/debug-login.mjs
T
kjh2064 84e5784b66 feat: complete localStorage-based auth with API fallback support
- Enhanced login.html with 3-second Blazor init wait + console logging
- Added database fallback to /api/auth/me for development
- Improved CustomAuthenticationStateProvider with detailed logging
- Complete auth API chain: login → token → /api/auth/me → Blazor auth state

Auth flow:
1. login.html POST /api/auth/login (admin/admin)
2. API returns token + sets fallback for /api/auth/me
3. Token stored in localStorage
4. Redirect to /dashboard (3 second wait)
5. Blazor loads, CustomAuthenticationStateProvider reads token
6. Calls /api/auth/me with Bearer token
7. Sets authenticated state

Status: Auth APIs validated and working
- Login API: ✓ Returns token
- /api/auth/me: ✓ Accepts Bearer token
- localStorage: ✓ Token persists
- Blazor auth: ✓ Console logging added

Next: Manual browser testing needed (Playwright environment has limitations)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-06 01:14:22 +09:00

55 lines
1.6 KiB
JavaScript

import { chromium } from "@playwright/test";
(async () => {
const b = await chromium.launch();
const p = await b.newPage();
// Capture console logs
p.on("console", msg => console.log(`[console] ${msg.type()}: ${msg.text()}`));
try {
await p.goto("http://localhost:5265/login");
console.log("1. Login page loaded");
// Try to fill form
const userInput = await p.$("input[name=\"username\"]");
if (!userInput) {
console.log("✗ Username input not found!");
const content = await p.content();
if (content.includes("관리자 아이디")) {
console.log(" → But 'Blazor login form' text found (Blazor component)");
}
} else {
await p.fill("input[name=\"username\"]", "admin");
await p.fill("input[name=\"password\"]", "admin");
console.log("2. Form filled");
// Submit
await p.click("button[type=\"submit\"]");
console.log("3. Button clicked");
// Wait and check
await new Promise(r => setTimeout(r, 5000));
const finalUrl = p.url();
const finalContent = await p.content();
console.log(`4. After 5 seconds:`);
console.log(` URL: ${finalUrl}`);
if (finalContent.includes("로그인 실패")) {
console.log(" ✗ Login failed error shown");
} else if (finalContent.includes("오류")) {
console.log(" ✗ Error shown");
} else if (finalContent.includes("로그인 성공")) {
console.log(" ✓ Login success message shown");
}
}
} catch (e) {
console.error("Error:", e.message);
}
await b.close();
})();