From f529e74f30e58f98b7ab2384c75dc3c69eab9afe Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Tue, 18 Oct 2022 16:50:03 +0200 Subject: [PATCH] Use env as redirect URL --- client/src/stores/user.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/src/stores/user.ts b/client/src/stores/user.ts index 09d6fb7c..83bc6bbe 100644 --- a/client/src/stores/user.ts +++ b/client/src/stores/user.ts @@ -3,6 +3,8 @@ import * as log from "loglevel"; import { itGet, itPost } from "@/fetchHelpers"; import { useAppStore } from "@/stores/app"; import { defineStore } from "pinia"; + +const logoutRedirectUrl = import.meta.env.VITE_LOGOUT_REDIRECT; // typed state https://stackoverflow.com/questions/71012513/when-using-pinia-and-typescript-how-do-you-use-an-action-to-set-the-state export type UserState = { @@ -53,7 +55,15 @@ export const useUserStore = defineStore({ handleLogout() { itPost("/api/core/logout/", {}).then((data) => { Object.assign(this, initialUserState); - window.location.href = "/"; + + let redirectUrl; + + if (logoutRedirectUrl !== "") { + redirectUrl = logoutRedirectUrl; + } else { + redirectUrl = "/"; + } + window.location.href = redirectUrl; }); }, fetchUser() {