Enhance authentication flow with improved error handling and logging in requireAuthHook. Refine HLS stream initialization and metadata fetching in AudioPlayer to handle station changes gracefully. Improve toast notifications and autocomplete behavior in LyricSearch. Simplify RandomMsg logic and remove unused imports. Add track and album count display in MediaRequestForm and enhance artist selection. Introduce dark mode styles for tables and dialogs in RequestManagement.css. Adjust imports and ensure proper usage of requireAuthHook in index.astro and requests.astro.
This commit is contained in:
@@ -17,6 +17,7 @@ export const requireAuthHook = async (Astro) => {
|
||||
});
|
||||
|
||||
if (!refreshRes.ok) {
|
||||
console.error("Token refresh failed", refreshRes.status);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,10 +25,13 @@ export const requireAuthHook = async (Astro) => {
|
||||
let newCookieHeader = cookieHeader;
|
||||
|
||||
if (setCookieHeader) {
|
||||
const cookiesArray = setCookieHeader.split(/,(?=\s*\w+=)/);
|
||||
const cookiesArray = setCookieHeader.split(/,(?=\s*\w+=)/);
|
||||
cookiesArray.forEach((c) => Astro.response.headers.append("set-cookie", c));
|
||||
|
||||
newCookieHeader = cookiesArray.map(c => c.split(";")[0]).join("; ");
|
||||
} else {
|
||||
console.error("No set-cookie header found in refresh response");
|
||||
return null;
|
||||
}
|
||||
|
||||
res = await fetch(`${API_URL}/auth/id`, {
|
||||
@@ -37,8 +41,10 @@ export const requireAuthHook = async (Astro) => {
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
console.error("Failed to fetch user ID after token refresh", res.status);
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = await res.json();
|
||||
return user;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user