diff --git a/backend/src/auth/auth.ts b/backend/src/auth/auth.ts index 12ab24feb..1103c0117 100644 --- a/backend/src/auth/auth.ts +++ b/backend/src/auth/auth.ts @@ -7,7 +7,10 @@ import decode from '../jwt/decode' export const isAuthorized: AuthChecker = ({ 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 } diff --git a/backend/src/graphql/inputs/TransactionInput.ts b/backend/src/graphql/inputs/TransactionInput.ts index 7f83cd82d..5365ab030 100644 --- a/backend/src/graphql/inputs/TransactionInput.ts +++ b/backend/src/graphql/inputs/TransactionInput.ts @@ -2,9 +2,6 @@ import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() export class TransactionListInput { - @Field(() => Number) - sessionId: number - @Field(() => Int) firstPage: number diff --git a/backend/src/graphql/resolvers/TransactionResolver.ts b/backend/src/graphql/resolvers/TransactionResolver.ts index 305cf44d7..31e46f13a 100644 --- a/backend/src/graphql/resolvers/TransactionResolver.ts +++ b/backend/src/graphql/resolvers/TransactionResolver.ts @@ -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 { 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) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index c025584f0..579e07912 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -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 diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 4081f4ceb..fdfea867d 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -111,7 +111,6 @@ export default { .query({ query: transactionsQuery, variables: { - sessionId: this.$store.state.sessionId, firstPage: pagination.firstPage, items: pagination.items, },