added session_limit, adapted ajax calls (axios interceptor) in theme
This commit is contained in:
@@ -5,7 +5,7 @@ import axios from 'axios'
|
||||
// console.log('drupalSettings', drupalSettings)
|
||||
console.log(window.location)
|
||||
|
||||
export const MGQ = axios.create({
|
||||
const MGQ = axios.create({
|
||||
baseURL: window.location.origin + '/mgq',
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -15,3 +15,19 @@ export const MGQ = axios.create({
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
MGQ.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in graphql-axios', status)
|
||||
if (status === 403) {
|
||||
window.location = '/'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default MGQ
|
||||
|
@@ -5,7 +5,7 @@ import axios from 'axios'
|
||||
// console.log('drupalSettings', drupalSettings)
|
||||
console.log(window.location)
|
||||
|
||||
export const JSONAPI = axios.create({
|
||||
const JSONAPI = axios.create({
|
||||
baseURL: window.location.origin+`/jsonapi`,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -14,3 +14,19 @@ export const JSONAPI = axios.create({
|
||||
// 'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
JSONAPI.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in json-axios', status)
|
||||
if (status === 403) {
|
||||
window.location = '/'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default JSONAPI
|
||||
|
@@ -4,7 +4,7 @@ import axios from 'axios'
|
||||
|
||||
// console.log('drupalSettings', drupalSettings)
|
||||
|
||||
export const MA = axios.create({
|
||||
const MA = axios.create({
|
||||
baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -12,3 +12,21 @@ export const MA = axios.create({
|
||||
// "X-CSRF-Token": "csrf_token"
|
||||
}
|
||||
})
|
||||
|
||||
MA.interceptors.response.use(
|
||||
response => {
|
||||
// console.log('ma-axios interceptor response', response)
|
||||
return Promise.resolve(response)
|
||||
// return response
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in ma-axios interceptor', status)
|
||||
if (status === 403) {
|
||||
window.location = '/'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default MA
|
||||
|
@@ -5,7 +5,7 @@ import axios from 'axios'
|
||||
// console.log('drupalSettings', drupalSettings)
|
||||
// console.log('window.location.origin', window.location.origin)
|
||||
|
||||
export const REST = axios.create({
|
||||
const REST = axios.create({
|
||||
baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
@@ -13,3 +13,19 @@ export const REST = axios.create({
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
REST.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
const { status } = error.response
|
||||
console.warn('error in rest-axios', status)
|
||||
if (status === 403) {
|
||||
window.location = '/'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default REST
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<script>
|
||||
import SearchForm from 'vuejs/components/Form/SearchForm'
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
|
||||
export default {
|
||||
props: ['blockid', 'formhtml'],
|
||||
|
@@ -9,7 +9,7 @@ import { mapState, mapActions } from 'vuex'
|
||||
import LoginBlock from 'vuejs/components/Block/LoginBlock'
|
||||
import UserTools from 'vuejs/components/User/UserTools'
|
||||
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
|
||||
export default {
|
||||
props: ['title', 'loginblock'],
|
||||
|
@@ -23,7 +23,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
|
||||
|
@@ -4,7 +4,7 @@ import Vue from 'vue'
|
||||
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
export default {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
import FlagCollection from 'vuejs/components/User/FlagCollection'
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
export default {
|
||||
|
@@ -301,8 +301,8 @@ import LinkedMaterialCard from 'vuejs/components/Content/LinkedMaterialCard'
|
||||
|
||||
import cardMixins from 'vuejs/components/cardMixins'
|
||||
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
import materiauFields from 'vuejs/api/gql/materiaumodal.fragment.gql'
|
||||
|
@@ -16,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import router from 'vuejs/route'
|
||||
|
||||
let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
|
||||
export default {
|
||||
name: "LoginForm",
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
|
||||
import passwordStrength from 'check-password-strength'
|
||||
|
||||
|
@@ -118,9 +118,9 @@
|
||||
import router from 'vuejs/route'
|
||||
import store from 'vuejs/store'
|
||||
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
// import materiauFields from 'vuejs/api/gql/materiau.fragment.gql'
|
||||
|
@@ -29,9 +29,9 @@
|
||||
import router from 'vuejs/route'
|
||||
import store from 'vuejs/store'
|
||||
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
// import materiauFields from 'vuejs/api/gql/materiau.fragment.gql'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// https://forum.vuejs.org/t/how-to-use-helper-functions-for-imported-modules-in-vuejs-vue-template/6266/5
|
||||
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
import Modal from 'vuejs/components/Helper/Modal'
|
||||
import LoginRegister from 'vuejs/components/Helper/LoginRegister'
|
||||
import { mapState } from 'vuex'
|
||||
|
@@ -3,10 +3,10 @@ import Vuex from 'vuex'
|
||||
|
||||
import { createStore } from 'vuex-extensions'
|
||||
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
// import qs from 'querystring-es3'
|
||||
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
// import materiauFields from 'vuejs/api/gql/materiau.fragment.gql'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { MA } from 'vuejs/api/ma-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
// import MA from 'vuejs/api/ma-axios'
|
||||
// import qs from 'querystring-es3'
|
||||
|
||||
export default {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
// import REST from 'vuejs/api/rest-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
// import qs from 'querystring-es3'
|
||||
|
||||
export default {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
import productsGQL from 'vuejs/api/gql/products.fragment.gql'
|
||||
|
@@ -1,11 +1,11 @@
|
||||
// import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
// import REST from 'vuejs/api/rest-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
import qs from 'querystring-es3'
|
||||
|
||||
import Vue from 'vue'
|
||||
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
import MGQ from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
import searchresultGQL from 'vuejs/api/gql/searchresults.fragment.gql'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { MA } from 'vuejs/api/ma-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
// import MA from 'vuejs/api/ma-axios'
|
||||
// import qs from 'querystring-es3'
|
||||
|
||||
export default {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { REST } from 'vuejs/api/rest-axios'
|
||||
// import { JSONAPI } from 'vuejs/api/json-axios'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import REST from 'vuejs/api/rest-axios'
|
||||
// import JSONAPI from 'vuejs/api/json-axios'
|
||||
import MA from 'vuejs/api/ma-axios'
|
||||
import qs from 'querystring-es3'
|
||||
|
||||
import materiauGQL from 'vuejs/api/gql/materiauflaglist.fragment.gql'
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
// state.username = data.username;
|
||||
state.mail = data.current_user.mail
|
||||
state.csrf_token = data.csrf_token
|
||||
state.isloggedin = true
|
||||
// state.isloggedin = true
|
||||
state.logout_token = data.logout_token
|
||||
},
|
||||
setLoginMessage (state, message) {
|
||||
@@ -64,6 +64,8 @@ export default {
|
||||
setUser (state, data) {
|
||||
state.mail = data.mail[0].value
|
||||
state.uuid = data.uuid[0].value
|
||||
// with session_limit, only here we are certain that the user is logged
|
||||
state.isloggedin = true
|
||||
},
|
||||
setRoles (state, roles) {
|
||||
console.log('User setRoles', roles)
|
||||
@@ -235,6 +237,7 @@ export default {
|
||||
.then(({ data }) => {
|
||||
console.log('user REST getUser data', data)
|
||||
console.log('roles', data.roles)
|
||||
// with session_limit, only here we are certain that the user is logged
|
||||
commit('setUser', data)
|
||||
if (data.roles) {
|
||||
commit('setRoles', data.roles)
|
||||
|
Reference in New Issue
Block a user