1
0
Fork 0
mirror of synced 2024-10-03 02:27:06 +13:00

Reload location on client logout for full reset, avoiding error when public pages exist

This commit is contained in:
Andrew Kingston 2021-07-25 13:29:27 +01:00
parent f32b4f94e7
commit e74d9a7312

View file

@ -1,20 +1,9 @@
import * as API from "../api" import * as API from "../api"
import { writable } from "svelte/store" import { writable } from "svelte/store"
import { initialise } from "./initialise"
import { routeStore } from "./routes"
const createAuthStore = () => { const createAuthStore = () => {
const store = writable(null) const store = writable(null)
const goToDefaultRoute = () => {
// Setting the active route forces an update of the active screen ID,
// even if we're on the same URL
routeStore.actions.setActiveRoute("/")
// Navigating updates the URL to reflect this route
routeStore.actions.navigate("/")
}
// Fetches the user object if someone is logged in and has reloaded the page // Fetches the user object if someone is logged in and has reloaded the page
const fetchUser = async () => { const fetchUser = async () => {
const user = await API.fetchSelf() const user = await API.fetchSelf()
@ -22,10 +11,8 @@ const createAuthStore = () => {
} }
const logOut = async () => { const logOut = async () => {
store.set(null)
window.document.cookie = `budibase:auth=; budibase:currentapp=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;` window.document.cookie = `budibase:auth=; budibase:currentapp=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
await initialise() window.location.reload()
goToDefaultRoute()
} }
return { return {