diff --git a/backend/main.py b/backend/main.py index 9450acec8..cc014540b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -63,6 +63,7 @@ if not IS_PYTEST_RUN and not DISABLE_CSRF_PROTECTION: # CSRF protection (except endpoints listed in exempt_urls) app.add_middleware( CustomCSRFMiddleware, + cookie_name="romm_csrftoken", secret=ROMM_AUTH_SECRET_KEY, exempt_urls=[re.compile(r"^/token.*"), re.compile(r"^/ws")], ) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 5efb060c3..5e38ff7a3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -5,50 +5,34 @@ import userApi from "@/services/api/user"; import storeAuth from "@/stores/auth"; import storeConfig from "@/stores/config"; import storeHeartbeat from "@/stores/heartbeat"; -import storeNotifications from "@/stores/notifications"; -import Cookies from "js-cookie"; -import { storeToRefs } from "pinia"; import { onBeforeMount } from "vue"; import router from "./plugins/router"; // Props -const notificationStore = storeNotifications(); -const { notifications } = storeToRefs(notificationStore); const heartbeat = storeHeartbeat(); const auth = storeAuth(); const configStore = storeConfig(); -onBeforeMount(async () => { - await api - .get("/heartbeat") - .then(async ({ data: data }) => { - heartbeat.set(data); - if (heartbeat.value.SHOW_SETUP_WIZARD) { - router.push({ name: "setup" }); - } else { - await userApi - .fetchCurrentUser() - .then(({ data: user }) => { - auth.setUser(user); - }) - .catch((error) => { - console.error(error); - }); - - await api.get("/config").then(({ data: data }) => { - configStore.set(data); +onBeforeMount(() => { + api.get("/heartbeat").then(async ({ data: data }) => { + heartbeat.set(data); + if (heartbeat.value.SHOW_SETUP_WIZARD) { + router.push({ name: "setup" }); + } else { + await userApi + .fetchCurrentUser() + .then(({ data: user }) => { + auth.setUser(user); + }) + .catch((error) => { + console.error(error); }); - } - }) - .catch(() => { - const allCookies = Cookies.get(); // Get all cookies - for (let cookie in allCookies) { - Cookies.remove(cookie); // Remove each cookie - } - router.push({ - name: "login", + + await api.get("/config").then(({ data: data }) => { + configStore.set(data); }); - }); + } + }); }); diff --git a/frontend/src/components/common/Navigation/SettingsDrawer.vue b/frontend/src/components/common/Navigation/SettingsDrawer.vue index 067e78e04..a218f3163 100644 --- a/frontend/src/components/common/Navigation/SettingsDrawer.vue +++ b/frontend/src/components/common/Navigation/SettingsDrawer.vue @@ -1,6 +1,7 @@