diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de743b6b0..dbf7e807e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,5 @@ name: gradido test CI - on: [push] jobs: diff --git a/backend/src/graphql/resolvers/BalanceResolver.ts b/backend/src/graphql/resolvers/BalanceResolver.ts index c42d3d101..34aedac37 100644 --- a/backend/src/graphql/resolvers/BalanceResolver.ts +++ b/backend/src/graphql/resolvers/BalanceResolver.ts @@ -5,8 +5,8 @@ import { Resolver, Query, Ctx, Authorized } from 'type-graphql' import CONFIG from '../../config' import { Balance } from '../models/Balance' import { apiGet } from '../../apis/HttpRequest' -import { User as tUser } from '../../typeorm/entity/User' -import { Balance as tBalance } from '../../typeorm/entity/Balance' +import { User as dbUser } from '../../typeorm/entity/User' +import { Balance as dbBalance } from '../../typeorm/entity/Balance' import calculateDecay from '../../util/decay' import { roundFloorFrom4 } from '../../util/round' @@ -20,8 +20,8 @@ export class BalanceResolver { if (!result.success) throw new Error(result.data) // load user and balance - const userEntity = await tUser.findByPubkeyHex(result.data.user.public_hex) - const balanceEntity = await tBalance.findByUser(userEntity.id) + const userEntity = await dbUser.findByPubkeyHex(result.data.user.public_hex) + const balanceEntity = await dbBalance.findByUser(userEntity.id) const now = new Date() const balance = new Balance({ balance: roundFloorFrom4(balanceEntity.amount), diff --git a/backend/src/graphql/resolvers/GdtResolver.ts b/backend/src/graphql/resolvers/GdtResolver.ts index 18365e9f9..4396c5ac9 100644 --- a/backend/src/graphql/resolvers/GdtResolver.ts +++ b/backend/src/graphql/resolvers/GdtResolver.ts @@ -6,6 +6,7 @@ import CONFIG from '../../config' import { GdtEntryList } from '../models/GdtEntryList' import { GdtTransactionSessionIdInput } from '../inputs/GdtInputs' import { apiGet } from '../../apis/HttpRequest' +import { User as dbUser } from '../../typeorm/entity/User' @Resolver() export class GdtResolver { @@ -17,13 +18,20 @@ export class GdtResolver { { currentPage = 1, pageSize = 5, order = 'DESC' }: GdtTransactionSessionIdInput, @Ctx() context: any, ): Promise { - const result = await apiGet( - `${CONFIG.COMMUNITY_API_URL}listGDTTransactions/${currentPage}/${pageSize}/${order}/${context.sessionId}`, + // get public key for current logged in user + const result = await apiGet(CONFIG.LOGIN_API_URL + 'login?session_id=' + context.sessionId) + if (!result.success) throw new Error(result.data) + + // load user + const userEntity = await dbUser.findByPubkeyHex(result.data.user.public_hex) + + const resultGDT = await apiGet( + `${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.email}/${currentPage}/${pageSize}/${order}`, ) - if (!result.success) { + if (!resultGDT.success) { throw new Error(result.data) } - return new GdtEntryList(result.data) + return new GdtEntryList(resultGDT.data) } } diff --git a/backend/src/graphql/resolvers/TransactionResolver.ts b/backend/src/graphql/resolvers/TransactionResolver.ts index 15de4d145..0e4106991 100644 --- a/backend/src/graphql/resolvers/TransactionResolver.ts +++ b/backend/src/graphql/resolvers/TransactionResolver.ts @@ -1,7 +1,7 @@ /* 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 { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import CONFIG from '../../config' import { TransactionList } from '../models/Transaction' import { TransactionListInput, TransactionSendArgs } from '../inputs/TransactionInput' @@ -49,7 +49,7 @@ export class TransactionResolver { } @Authorized() - @Query(() => String) + @Mutation(() => String) async sendCoins( @Args() { email, amount, memo }: TransactionSendArgs, @Ctx() context: any, diff --git a/backend/src/graphql/resolvers/UserResolver.ts b/backend/src/graphql/resolvers/UserResolver.ts index 7e618cf42..06b10daec 100644 --- a/backend/src/graphql/resolvers/UserResolver.ts +++ b/backend/src/graphql/resolvers/UserResolver.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware } from 'type-graphql' +import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql' import CONFIG from '../../config' import { CheckUsernameResponse } from '../models/CheckUsernameResponse' import { LoginViaVerificationCode } from '../models/LoginViaVerificationCode' @@ -66,8 +66,8 @@ export class UserResolver { return 'success' } - @Query(() => String) - async create( + @Mutation(() => String) + async createUser( @Args() { email, firstName, lastName, password, language }: CreateUserArgs, ): Promise { const payload = { @@ -104,7 +104,7 @@ export class UserResolver { return new SendPasswordResetEmailResponse(response.data) } - @Query(() => String) + @Mutation(() => String) async resetPassword( @Args() { sessionId, email, password }: ChangePasswordArgs, @@ -122,7 +122,7 @@ export class UserResolver { } @Authorized() - @Query(() => UpdateUserInfosResponse) + @Mutation(() => UpdateUserInfosResponse) async updateUserInfos( @Args() { diff --git a/backend/src/jwt/decode.ts b/backend/src/jwt/decode.ts index 47cf62154..2e24386b3 100644 --- a/backend/src/jwt/decode.ts +++ b/backend/src/jwt/decode.ts @@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken' import CONFIG from '../config/' export default (token: string): any => { - if (!token) return null + if (!token) return new Error('401 Unauthorized') let sessionId = null try { const decoded = jwt.verify(token, CONFIG.JWT_SECRET) @@ -15,6 +15,6 @@ export default (token: string): any => { sessionId, } } catch (err) { - return null + throw new Error('403.13 - Client certificate revoked') } } diff --git a/frontend/src/components/DecayInformation.vue b/frontend/src/components/DecayInformation.vue index 24acbd47e..470f45dc7 100644 --- a/frontend/src/components/DecayInformation.vue +++ b/frontend/src/components/DecayInformation.vue @@ -19,11 +19,11 @@ -
-
+ +
{{ $t('decay.last_transaction') }}
-
-
+ +
{{ $t('decay.Starting_block_decay') }}
@@ -32,19 +32,18 @@
- + {{ $d($moment.unix(decay.decayStart), 'long') }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }}
-
-
- -
-
+ + + +
{{ $t('decay.past_time') }}
-
-
+ +
{{ $t('decay.since_introduction') }}
{{ duration.years }} {{ $t('decay.year') }}, @@ -60,7 +59,59 @@ {{ duration.seconds }} {{ $t('decay.seconds') }} -
+ + + +
+ + + +
{{ $t('decay.decay') }}
+
+ +
- {{ decay.balance }}
+
+
+
+ + + {{ $t('decay.calculation_total') }} + + + + + +
{{ $t('decay.sent') }}
+
{{ $t('decay.received') }}
+
+ +
- {{ balance }}
+
+ {{ balance }}
+
+
+ + + +
{{ $t('decay.decay') }}
+
+ +
- {{ decay.balance }}
+
+
+ + + +
{{ $t('decay.total') }}
+
+ +
+ - {{ parseInt(balance) + decay.balance }} +
+
+ {{ parseInt(balance) - decay.balance }} +
+
+
@@ -71,6 +122,8 @@ export default { name: 'DecayInformation', props: { + balance: { type: Number }, + type: { type: String, default: '' }, decay: { balance: '', decayDuration: '', diff --git a/frontend/src/components/LanguageSwitch.spec.js b/frontend/src/components/LanguageSwitch.spec.js index afe98b357..dc76d854b 100644 --- a/frontend/src/components/LanguageSwitch.spec.js +++ b/frontend/src/components/LanguageSwitch.spec.js @@ -3,7 +3,7 @@ import LanguageSwitch from './LanguageSwitch' const localVue = global.localVue -const updateUserInfosQueryMock = jest.fn().mockResolvedValue({ +const updateUserInfosMutationMock = jest.fn().mockResolvedValue({ data: { updateUserInfos: { validValues: 1, @@ -28,7 +28,7 @@ describe('LanguageSwitch', () => { locale: 'en', }, $apollo: { - query: updateUserInfosQueryMock, + mutate: updateUserInfosMutationMock, }, } @@ -119,7 +119,7 @@ describe('LanguageSwitch', () => { describe('calls the API', () => { it("with locale 'en'", () => { wrapper.findAll('li').at(0).find('a').trigger('click') - expect(updateUserInfosQueryMock).toBeCalledWith( + expect(updateUserInfosMutationMock).toBeCalledWith( expect.objectContaining({ variables: { email: 'he@ho.he', @@ -131,7 +131,7 @@ describe('LanguageSwitch', () => { it("with locale 'de'", () => { wrapper.findAll('li').at(1).find('a').trigger('click') - expect(updateUserInfosQueryMock).toBeCalledWith( + expect(updateUserInfosMutationMock).toBeCalledWith( expect.objectContaining({ variables: { email: 'he@ho.he', diff --git a/frontend/src/components/LanguageSwitch.vue b/frontend/src/components/LanguageSwitch.vue index f0528a935..14894e46e 100644 --- a/frontend/src/components/LanguageSwitch.vue +++ b/frontend/src/components/LanguageSwitch.vue @@ -14,7 +14,7 @@ - +