1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-05-02 16:10:02 +00:00
bramw_baserow/web-frontend/modules/database/store/view/public.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
998 B
JavaScript
Raw Normal View History

import { getToken, setToken } from '@baserow/modules/core/utils/auth'
export const state = () => ({
authToken: null,
2022-07-27 11:19:29 +00:00
isPublic: false,
})
export const mutations = {
SET_AUTH_TOKEN(state, value) {
state.authToken = value
},
2022-07-27 11:19:29 +00:00
SET_IS_PUBLIC(state, value) {
state.isPublic = value
},
}
export const actions = {
setAuthTokenFromCookiesIfNotSet({ state, commit }, { slug }) {
if (!state.authToken) {
const token = getToken(this.app, slug)
commit('SET_AUTH_TOKEN', token)
return token
} else {
return state.authToken
}
},
setAuthToken({ commit }, { slug, token }) {
setToken(this.app, token, slug)
commit('SET_AUTH_TOKEN', token)
},
2022-07-27 11:19:29 +00:00
setIsPublic({ commit }, value) {
commit('SET_IS_PUBLIC', value)
},
}
export const getters = {
getAuthToken(state) {
return state.authToken
},
2022-07-27 11:19:29 +00:00
getIsPublic(state) {
return state.isPublic
},
}
export default {
namespaced: true,
state,
getters,
actions,
mutations,
}