Add response structure validation in auth token refresh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 14:10:36 +08:00
parent b5dfae9835
commit 387993da92

View File

@@ -34,8 +34,11 @@ export async function refreshTokenAndGetNew() {
};
const response = await axios.post(api, data, config);
const newAccessToken = response.data.access_token;
const newRefreshToken = response.data.refresh_token;
const newAccessToken = response.data?.access_token;
const newRefreshToken = response.data?.refresh_token;
if (!newAccessToken || !newRefreshToken) {
throw new Error("Invalid token response structure");
}
setCookieWithoutExpiration("luciaToken", newAccessToken);
// Expire in ~6 months