mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into e2e-test-setup
This commit is contained in:
commit
a411dbe761
@ -10,6 +10,7 @@ const authLink = new ApolloLink((operation, forward) => {
|
||||
operation.setContext({
|
||||
headers: {
|
||||
Authorization: token && token.length > 0 ? `Bearer ${token}` : '',
|
||||
clientRequestTime: new Date().toString(),
|
||||
},
|
||||
})
|
||||
return forward(operation).map((response) => {
|
||||
|
||||
@ -94,6 +94,7 @@ describe('apolloProvider', () => {
|
||||
expect(setContextMock).toBeCalledWith({
|
||||
headers: {
|
||||
Authorization: 'Bearer some-token',
|
||||
clientRequestTime: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
@ -109,6 +110,7 @@ describe('apolloProvider', () => {
|
||||
expect(setContextMock).toBeCalledWith({
|
||||
headers: {
|
||||
Authorization: '',
|
||||
clientRequestTime: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@ -9,6 +9,7 @@ export interface Context {
|
||||
setHeaders: { key: string; value: string }[]
|
||||
role?: Role
|
||||
user?: dbUser
|
||||
clientRequestTime?: string
|
||||
// hack to use less DB calls for Balance Resolver
|
||||
lastTransaction?: dbTransaction
|
||||
transactionCount?: number
|
||||
@ -18,14 +19,17 @@ export interface Context {
|
||||
|
||||
const context = (args: ExpressContext): Context => {
|
||||
const authorization = args.req.headers.authorization
|
||||
let token: string | null = null
|
||||
if (authorization) {
|
||||
token = authorization.replace(/^Bearer /, '')
|
||||
}
|
||||
const context = {
|
||||
token,
|
||||
const clientRequestTime = args.req.headers.clientrequesttime
|
||||
const context: Context = {
|
||||
token: null,
|
||||
setHeaders: [],
|
||||
}
|
||||
if (authorization) {
|
||||
context.token = authorization.replace(/^Bearer /, '')
|
||||
}
|
||||
if (clientRequestTime && typeof clientRequestTime === 'string') {
|
||||
context.clientRequestTime = clientRequestTime
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ const authLink = new ApolloLink((operation, forward) => {
|
||||
operation.setContext({
|
||||
headers: {
|
||||
Authorization: token && token.length > 0 ? `Bearer ${token}` : '',
|
||||
clientRequestTime: new Date().toString(),
|
||||
},
|
||||
})
|
||||
return forward(operation).map((response) => {
|
||||
|
||||
@ -98,6 +98,7 @@ describe('apolloProvider', () => {
|
||||
expect(setContextMock).toBeCalledWith({
|
||||
headers: {
|
||||
Authorization: 'Bearer some-token',
|
||||
clientRequestTime: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
@ -113,6 +114,7 @@ describe('apolloProvider', () => {
|
||||
expect(setContextMock).toBeCalledWith({
|
||||
headers: {
|
||||
Authorization: '',
|
||||
clientRequestTime: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user