mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Authorization Bearer in Header
This commit is contained in:
parent
6eea07d669
commit
8ec55b0a43
@ -3,7 +3,7 @@ import DashboardPlugin from './plugins/dashboard-plugin'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import i18n from './i18n.js'
|
import i18n from './i18n.js'
|
||||||
import { loadAllRules } from './validation-rules'
|
import { loadAllRules } from './validation-rules'
|
||||||
import ApolloClient from 'apollo-boost'
|
import { ApolloClient, ApolloLink, InMemoryCache, HttpLink } from 'apollo-boost'
|
||||||
import VueApollo from 'vue-apollo'
|
import VueApollo from 'vue-apollo'
|
||||||
import CONFIG from './config'
|
import CONFIG from './config'
|
||||||
|
|
||||||
@ -11,7 +11,21 @@ import { store } from './store/store'
|
|||||||
|
|
||||||
import router from './routes/router'
|
import router from './routes/router'
|
||||||
|
|
||||||
|
const httpLink = new HttpLink({ uri: CONFIG.GRAPHQL_URI })
|
||||||
|
|
||||||
|
const authLink = new ApolloLink((operation, forward) => {
|
||||||
|
const token = store.state.token
|
||||||
|
operation.setContext({
|
||||||
|
headers: {
|
||||||
|
Authorization: token && token.length > 0 ? `Bearer ${token}` : '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return forward(operation)
|
||||||
|
})
|
||||||
|
|
||||||
const apolloClient = new ApolloClient({
|
const apolloClient = new ApolloClient({
|
||||||
|
link: authLink.concat(httpLink),
|
||||||
|
cache: new InMemoryCache(),
|
||||||
uri: CONFIG.GRAPHQL_URI,
|
uri: CONFIG.GRAPHQL_URI,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -51,14 +51,15 @@ export const actions = {
|
|||||||
commit('firstName', '')
|
commit('firstName', '')
|
||||||
commit('lastName', '')
|
commit('lastName', '')
|
||||||
commit('description', '')
|
commit('description', '')
|
||||||
sessionStorage.clear()
|
commit('token', null)
|
||||||
|
localStorage.clear()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const store = new Vuex.Store({
|
export const store = new Vuex.Store({
|
||||||
plugins: [
|
plugins: [
|
||||||
createPersistedState({
|
createPersistedState({
|
||||||
storage: window.sessionStorage,
|
storage: window.localStorage,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
state: {
|
state: {
|
||||||
@ -69,6 +70,7 @@ export const store = new Vuex.Store({
|
|||||||
lastName: '',
|
lastName: '',
|
||||||
username: '',
|
username: '',
|
||||||
description: '',
|
description: '',
|
||||||
|
token: null,
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
// Syncronous mutation of the state
|
// Syncronous mutation of the state
|
||||||
|
|||||||
@ -107,7 +107,6 @@ export default {
|
|||||||
},
|
},
|
||||||
async updateTransactions(pagination) {
|
async updateTransactions(pagination) {
|
||||||
this.pending = true
|
this.pending = true
|
||||||
console.log('Session ID', this.$store.state.sessionId)
|
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.query({
|
||||||
query: transactionsQuery,
|
query: transactionsQuery,
|
||||||
@ -119,11 +118,9 @@ export default {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log(result)
|
|
||||||
const {
|
const {
|
||||||
data: { transactionList },
|
data: { transactionList },
|
||||||
} = result
|
} = result
|
||||||
console.log(transactionList)
|
|
||||||
this.GdtBalance = Number(transactionList.gdtSum)
|
this.GdtBalance = Number(transactionList.gdtSum)
|
||||||
this.transactions = transactionList.transactions
|
this.transactions = transactionList.transactions
|
||||||
this.balance = Number(transactionList.decay)
|
this.balance = Number(transactionList.decay)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user