Use env as redirect URL

This commit is contained in:
Christian Cueni 2022-10-18 16:50:03 +02:00
parent 7fbac1aaea
commit f529e74f30
1 changed files with 11 additions and 1 deletions

View File

@ -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() {