mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
sessionId from JWT into context for resolver
This commit is contained in:
parent
7eec6faace
commit
b2cdc69716
@ -7,7 +7,10 @@ import decode from '../jwt/decode'
|
||||
export const isAuthorized: AuthChecker<any> = ({ root, args, context, info }, roles) => {
|
||||
if (context.token) {
|
||||
const decoded = decode(context.token)
|
||||
if (decoded.sessionId && decoded.sessionId !== 0) return true
|
||||
if (decoded.sessionId && decoded.sessionId !== 0) {
|
||||
context.sessionId = decoded.sessionId
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ -2,9 +2,6 @@ import { ArgsType, Field, Int } from 'type-graphql'
|
||||
|
||||
@ArgsType()
|
||||
export class TransactionListInput {
|
||||
@Field(() => Number)
|
||||
sessionId: number
|
||||
|
||||
@Field(() => Int)
|
||||
firstPage: number
|
||||
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { Resolver, Query, Args, Authorized } from 'type-graphql'
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { Resolver, Query, Args, Authorized, Ctx } from 'type-graphql'
|
||||
import CONFIG from '../../config'
|
||||
import { TransactionList } from '../models/Transaction'
|
||||
import { TransactionListInput, TransactionSendArgs } from '../inputs/TransactionInput'
|
||||
@ -9,10 +12,11 @@ export class TransactionResolver {
|
||||
@Authorized()
|
||||
@Query(() => TransactionList)
|
||||
async transactionList(
|
||||
@Args() { sessionId, firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput,
|
||||
@Args() { firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput,
|
||||
@Ctx() context: any,
|
||||
): Promise<TransactionList> {
|
||||
const result = await apiGet(
|
||||
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`,
|
||||
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${context.sessionId}`,
|
||||
)
|
||||
if (!result.success) throw new Error(result.data)
|
||||
return new TransactionList(result.data)
|
||||
|
||||
@ -56,8 +56,8 @@ export const updateUserInfos = gql`
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query($sessionId: Float!, $firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") {
|
||||
transactionList(sessionId: $sessionId, firstPage: $firstPage, items: $items, order: $order) {
|
||||
query($firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") {
|
||||
transactionList(firstPage: $firstPage, items: $items, order: $order) {
|
||||
gdtSum
|
||||
count
|
||||
balance
|
||||
|
||||
@ -111,7 +111,6 @@ export default {
|
||||
.query({
|
||||
query: transactionsQuery,
|
||||
variables: {
|
||||
sessionId: this.$store.state.sessionId,
|
||||
firstPage: pagination.firstPage,
|
||||
items: pagination.items,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user