Files
taxbaik/legacy/smartadmin/scripts/pages/position.js
T
kjh2064 40cffb3beb
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m26s
fix: implement Blazor-native login form to properly update authentication state
Problem: JavaScript login form saved tokens to localStorage but didn't notify
CustomAuthenticationStateProvider, causing [Authorize] pages to remain in
'loading' state indefinitely. The provider only reads tokens when:
1. GetAuthenticationStateAsync() is called (page load)
2. NotifyAuthenticationStateChanged() is triggered (UI updates)

But JavaScript login didn't trigger either, leaving the authentication state
stale.

Solution: Convert AdminLoginForm from HTML+JavaScript to pure Blazor component.
Now the login flow is:
1. User enters credentials in Blazor form
2. HttpClient POST to /api/auth/login
3. Save tokens to localStorage
4. Call CustomAuthenticationStateProvider.LoginAsync() directly
5. Blazor detects auth state change and re-evaluates [Authorize] pages
6. Dashboard [Authorize] page renders successfully

Result: Immediate authentication state update, no loading timeout on protected pages.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-03 13:03:53 +09:00

24 lines
1.1 KiB
JavaScript

function swapPositions() {
// Toggle the 'position-relative' class on the element with id 'js-position-change'
var positionChangeEl = document.getElementById("js-position-change");
if (positionChangeEl) {
positionChangeEl.classList.toggle("position-relative");
}
// Helper function to toggle text content between two given strings
function toggleText(element, text1, text2) {
if (!element) return;
// Check current text (trimmed of whitespace)
if (element.textContent.trim() === text1) {
element.textContent = text2;
}
else {
element.textContent = text1;
}
}
// Toggle the text for the element with id 'js-position-text'
var positionTextEl = document.getElementById("js-position-text");
toggleText(positionTextEl, ".position-static", ".position-relative");
// Toggle the text for the element with id 'js-position-btn'
var positionBtnEl = document.getElementById("js-position-btn");
toggleText(positionBtnEl, "Change to RELATIVE", "Change to STATIC");
}