From 42df93b9e6d046ef178a72813a3bdd4e48f1570a Mon Sep 17 00:00:00 2001 From: Clas Wen Date: Fri, 10 Oct 2025 19:11:15 +0800 Subject: [PATCH] Improve authentication error handling and update dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add try-catch block for authentication check in TicketForm - Handle authentication errors gracefully with proper error logging - Update caniuse-lite dependency to latest version 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- pnpm-lock.yaml | 17 ++++++----------- src/pages/repair/TicketForm.tsx | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d50e08..26711d3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2966,11 +2966,8 @@ packages: resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} engines: {node: '>=16'} - caniuse-lite@1.0.30001715: - resolution: {integrity: sha512-7ptkFGMm2OAOgvZpwgA4yjQ5SQbrNVGdRjzH0pBdy1Fasvcr+KAeECmbCAECzTuDuoX0FCY8KzUxjf9+9kfZEw==} - - caniuse-lite@1.0.30001735: - resolution: {integrity: sha512-EV/laoX7Wq2J9TQlyIXRxTJqIw4sxfXS4OYgudGxBYRuTv0q7AM6yMEpU/Vo1I94thg9U6EZ2NfZx9GJq83u7w==} + caniuse-lite@1.0.30001747: + resolution: {integrity: sha512-mzFa2DGIhuc5490Nd/G31xN1pnBnYMadtkyTjefPI7wzypqgCEpeWu9bJr0OnDsyKrW75zA9ZAt7pbQFmwLsQg==} ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -9515,7 +9512,7 @@ snapshots: autoprefixer@10.4.21(postcss@8.5.3): dependencies: browserslist: 4.24.4 - caniuse-lite: 1.0.30001715 + caniuse-lite: 1.0.30001747 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.1.1 @@ -9564,14 +9561,14 @@ snapshots: browserslist@4.24.4: dependencies: - caniuse-lite: 1.0.30001715 + caniuse-lite: 1.0.30001747 electron-to-chromium: 1.5.141 node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.24.4) browserslist@4.25.3: dependencies: - caniuse-lite: 1.0.30001735 + caniuse-lite: 1.0.30001747 electron-to-chromium: 1.5.207 node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.25.3) @@ -9631,9 +9628,7 @@ snapshots: camelcase@8.0.0: {} - caniuse-lite@1.0.30001715: {} - - caniuse-lite@1.0.30001735: {} + caniuse-lite@1.0.30001747: {} ccount@2.0.1: {} diff --git a/src/pages/repair/TicketForm.tsx b/src/pages/repair/TicketForm.tsx index 0ac6e82..d4020bb 100644 --- a/src/pages/repair/TicketForm.tsx +++ b/src/pages/repair/TicketForm.tsx @@ -145,13 +145,19 @@ export default function App() { useEffect(() => { const check = async () => { const createRepairPath = "/repair/create-ticket" - const authenticated = await makeLogtoClient().isAuthenticated() - if (!authenticated) { - window.location.href = `/repair/login-hint?redirectUrl=${createRepairPath}` - return + try { + const authenticated = await makeLogtoClient().isAuthenticated() + if (!authenticated) { + window.location.href = `/repair/login-hint?redirectUrl=${createRepairPath}` + return + } + const res = await makeLogtoClient().getIdTokenClaims() + setUserInfo(res) + } + catch (error) { + console.error("Error checking authentication:", error) + window.location.href = `/repair/login-hint?redirectUrl=${createRepairPath}` } - const res = await makeLogtoClient().getIdTokenClaims() - setUserInfo(res) } check() }, [])