diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js
index a451cb19..6a5c3e92 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js
@@ -1,12 +1,28 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import axios from 'axios';
+import Vue from 'vue'
+import Vuex from 'vuex'
+import axios from 'axios'
+import EventBus from '../_bus'
+
+const configElement = document.getElementById('appconfig');
+const config = JSON.parse(configElement.innerHTML);
+
+axios.defaults.headers.common['Accept'] = 'application/json';
+axios.defaults.headers.put['Content-Type'] = 'application/json';
+axios.defaults.baseURL = config.myEpApiBaseUrl;
+
+const createAuthenticatingClient = () => {
+ return axios.create({
+ headers: {
+ 'X-Auth-Token': sessionStorage.getItem('token')
+ },
+ });
+};
Vue.use(Vuex);
export default new Vuex.Store({
state: {
- config: {},
+ config: config,
loading: false,
loggedIn: !!sessionStorage.getItem('token'),
countries: []
@@ -29,9 +45,6 @@ export default new Vuex.Store({
},
setCountries (state, countries) {
state.countries = countries;
- },
- setConfig (state, config) {
- state.config = config;
}
},
actions: {
@@ -89,81 +102,82 @@ export default new Vuex.Store({
},
loadAddress ({ commit }) {
commit('loadingBegin');
- return axios({
- url: '/api/addresses',
- headers: {
- 'x-auth-token': sessionStorage.getItem('token')
- }
- }).then((response) => {
- commit('loadingFinish');
- return response.data[0];
- }).catch((error) => {
- commit('loadingFinish');
- throw error;
- });
+
+ const client = createAuthenticatingClient();
+
+ return client.get('/api/addresses')
+ .then((response) => {
+ commit('loadingFinish');
+ return response.data[0];
+ }).catch((error) => {
+ commit('loadingFinish');
+ commit('logout');
+ EventBus.$emit('forcedLogout');
+ throw error;
+ });
},
saveAddress ({ commit }, data) {
commit('loadingBegin');
- return axios({
- url: '/api/addresses/' + data.id,
- headers: {
- 'x-auth-token': sessionStorage.getItem('token')
- },
- method: 'PUT',
- data: data
- }).then(() => {
- commit('loadingFinish');
- })
- .catch((error) => {
- commit('loadingFinish');
- throw error;
- });
+
+ const client = createAuthenticatingClient();
+
+ return client.put('/api/addresses/' + data.id, data)
+ .then(() => {
+ commit('loadingFinish');
+ })
+ .catch((error) => {
+ commit('loadingFinish');
+ commit('logout');
+ EventBus.$emit('forcedLogout');
+ throw error;
+ });
},
loadEvents ({ commit }) {
commit('loadingBegin');
- return axios({
- url: '/api/events',
- headers: {
- 'x-auth-token': sessionStorage.getItem('token')
- }
- }).then((response) => {
+
+ const client = createAuthenticatingClient();
+
+ return client.get('/api/events')
+ .then((response) => {
commit('loadingFinish');
return response.data;
}).catch((error) => {
commit('loadingFinish');
+ commit('logout');
+ EventBus.$emit('forcedLogout');
throw error;
});
},
loadCrmData ({ commit }) {
commit('loadingBegin');
- return axios({
- url: '/api/crm-selections',
- headers: {
- 'x-auth-token': sessionStorage.getItem('token')
- }
- }).then((response) => {
- commit('loadingFinish');
- return response.data[0];
- }).catch((error) => {
- commit('loadingFinish');
- throw error;
- });
+
+ const client = createAuthenticatingClient();
+
+ return client.get('/api/crm-selections')
+ .then((response) => {
+ commit('loadingFinish');
+ return response.data[0];
+ }).catch((error) => {
+ commit('loadingFinish');
+ commit('logout');
+ EventBus.$emit('forcedLogout');
+ throw error;
+ });
},
saveCrmData ({ commit }, data) {
commit('loadingBegin');
- return axios({
- url: '/api/crm-selections/' + data.id,
- headers: {
- 'x-auth-token': sessionStorage.getItem('token')
- },
- method: 'PUT',
- data: data
- }).then(() => {
- commit('loadingFinish');
- }).catch((error) => {
- commit('loadingFinish');
- throw error;
- });
+
+ const client = createAuthenticatingClient();
+
+ return client.put('/api/crm-selections/' + data.id, data)
+ .then(() => {
+ commit('loadingFinish');
+ }).catch((error) => {
+ commit('loadingFinish');
+ commit('logout');
+ EventBus.$emit('forcedLogout');
+ throw error;
+ });
}
},
getters: {
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue
index 4d08fb53..d2264b38 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue
@@ -7,7 +7,7 @@
{{ message }}
-
+