mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-18 16:25:20 -05:00
fix: Actually Fix Token Time (#6215)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { defineNuxtConfig } from "nuxt/config";
|
||||
|
||||
const AUTH_TOKEN = "mealie.auth.token";
|
||||
const AUTH_TOKEN = "mealie.access_token";
|
||||
|
||||
export default defineNuxtConfig({
|
||||
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||
@@ -142,7 +142,6 @@ export default defineNuxtConfig({
|
||||
signInResponseTokenPointer: "/access_token",
|
||||
type: "Bearer",
|
||||
cookieName: AUTH_TOKEN,
|
||||
maxAgeInSeconds: parseInt(process.env.TOKEN_TIME || "48") * 3600, // TOKEN_TIME is in hours
|
||||
},
|
||||
pages: {
|
||||
login: "/login",
|
||||
|
||||
@@ -30,7 +30,23 @@ export default defineNuxtPlugin(() => {
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
if (error?.response?.data?.detail?.message) alert.error(error.response.data.detail.message as string);
|
||||
if (error?.response?.data?.detail?.message) {
|
||||
alert.error(error.response.data.detail.message as string);
|
||||
};
|
||||
|
||||
// If we receive a 401 Unauthorized response, clear the token cookie and redirect to login
|
||||
if (error?.response?.status === 401) {
|
||||
// If tokenCookie is not set, we may just be an unauthenticated user using the wrong API, so don't redirect
|
||||
const tokenCookie = useCookie(tokenName);
|
||||
if (tokenCookie.value) {
|
||||
tokenCookie.value = null;
|
||||
|
||||
// Disable beforeunload warnings to prevent "Are you sure you want to leave?" popups
|
||||
window.onbeforeunload = null;
|
||||
window.location.href = "/login";
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user