Merge pull request #2087 from Budibase/fix/log-out-action
Logout button handler
This commit is contained in:
commit
c3bf5b0a66
|
@ -6,8 +6,15 @@ const createAppStore = () => {
|
||||||
|
|
||||||
// Fetches the app definition including screens, layouts and theme
|
// Fetches the app definition including screens, layouts and theme
|
||||||
const fetchAppDefinition = async () => {
|
const fetchAppDefinition = async () => {
|
||||||
const appDefinition = await API.fetchAppPackage(get(store).appId)
|
const appId = get(store)?.appId
|
||||||
store.set(appDefinition)
|
if (!appId) {
|
||||||
|
throw "Cannot fetch app definition without app ID set"
|
||||||
|
}
|
||||||
|
const appDefinition = await API.fetchAppPackage(appId)
|
||||||
|
store.set({
|
||||||
|
...appDefinition,
|
||||||
|
appId: appDefinition?.application?.appId,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the initial app ID
|
// Sets the initial app ID
|
||||||
|
|
|
@ -10,9 +10,14 @@ const createAuthStore = () => {
|
||||||
store.set(user)
|
store.set(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logOut = async () => {
|
||||||
|
window.document.cookie = `budibase:auth=; budibase:currentapp=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
|
||||||
|
window.location = "/builder/auth/login"
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe: store.subscribe,
|
subscribe: store.subscribe,
|
||||||
actions: { fetchUser },
|
actions: { fetchUser, logOut },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { routeStore, builderStore, confirmationStore } from "../store"
|
import {
|
||||||
|
routeStore,
|
||||||
|
builderStore,
|
||||||
|
confirmationStore,
|
||||||
|
authStore,
|
||||||
|
} from "../store"
|
||||||
import { saveRow, deleteRow, executeQuery, triggerAutomation } from "../api"
|
import { saveRow, deleteRow, executeQuery, triggerAutomation } from "../api"
|
||||||
import { ActionTypes } from "../constants"
|
import { ActionTypes } from "../constants"
|
||||||
|
|
||||||
|
@ -77,6 +82,10 @@ const refreshDatasourceHandler = async (action, context) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logoutHandler = async () => {
|
||||||
|
await authStore.actions.logOut()
|
||||||
|
}
|
||||||
|
|
||||||
const handlerMap = {
|
const handlerMap = {
|
||||||
["Save Row"]: saveRowHandler,
|
["Save Row"]: saveRowHandler,
|
||||||
["Delete Row"]: deleteRowHandler,
|
["Delete Row"]: deleteRowHandler,
|
||||||
|
@ -85,6 +94,7 @@ const handlerMap = {
|
||||||
["Trigger Automation"]: triggerAutomationHandler,
|
["Trigger Automation"]: triggerAutomationHandler,
|
||||||
["Validate Form"]: validateFormHandler,
|
["Validate Form"]: validateFormHandler,
|
||||||
["Refresh Datasource"]: refreshDatasourceHandler,
|
["Refresh Datasource"]: refreshDatasourceHandler,
|
||||||
|
["Log Out"]: logoutHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmTextMap = {
|
const confirmTextMap = {
|
||||||
|
|
Loading…
Reference in New Issue