Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/pages/appeal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ const AppealPage: React.FC = () => {

async function checkBan() {
try {
// Verify we have a token in sessionStorage before attempting API calls
const savedToken = sessionStorage.getItem("kc_token");
if (!savedToken) {
setBanStatus("unknown");
setLoading(false);
return;
}

// Get auth headers once and reuse them for all requests in this function
const headers = await getAuthHeaders();

Expand Down Expand Up @@ -350,14 +358,18 @@ const AppealPage: React.FC = () => {
const checkToken = async () => {
const validToken = await refreshTokenIfNeeded();
if (validToken) {
// Ensure token state is set BEFORE any other operations
setToken(validToken);
// The token useEffect at line 403 will trigger checkBan() when token is set
} else {
// Look for auth code for fresh login
const params = new URLSearchParams(window.location.search);
const code = params.get("code");
if (code) {
// exchangeCodeForToken handles both setToken and setLoading
exchangeCodeForToken(code);
} else {
// Only set loading to false if there's truly no token and no code
setLoading(false);
}
}
Expand Down
Loading