diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 85cb3a0fe..cb23ed577 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -1,4 +1,4 @@ -import { Resolver, Query, Arg, Args, Authorized, Mutation } from 'type-graphql' +import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx } from 'type-graphql' import { getCustomRepository, Raw } from 'typeorm' import { UserAdmin } from '../model/UserAdmin' import { PendingCreation } from '../model/PendingCreation' @@ -66,7 +66,7 @@ export class AdminResolver { return await getUserCreations(user.id) } - // @Authorized([RIGHTS.SEARCH_USERS]) + @Authorized([RIGHTS.SEARCH_USERS]) @Mutation(() => UpdatePendingCreation) async updatePendingCreation( @Args() { id, email, amount, memo, creationDate, moderator }: UpdatePendingCreationArgs, @@ -94,24 +94,9 @@ export class AdminResolver { result.creation = await getUserCreations(user.id) return result - - // const creations = await getUserCreations(user.id) - // const creationDateObj = new Date(creationDate) - // if (isCreationValid(creations, amount, creationDateObj)) { - // const pendingCreationRepository = getCustomRepository(PendingCreationRepository) - // const loginPendingTaskAdmin = pendingCreationRepository.create() - // loginPendingTaskAdmin.userId = user.id - // loginPendingTaskAdmin.amount = BigInt(amount * 10000) - // loginPendingTaskAdmin.created = new Date() - // loginPendingTaskAdmin.date = creationDateObj - // loginPendingTaskAdmin.memo = memo - // loginPendingTaskAdmin.moderator = moderator - // - // pendingCreationRepository.save(loginPendingTaskAdmin) - // } - // return await getUserCreations(user.id) } + @Authorized([RIGHTS.SEARCH_USERS]) @Query(() => [PendingCreation]) async getPendingCreations(): Promise { const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository) @@ -139,6 +124,7 @@ export class AdminResolver { return pendingCreationsPromise.reverse() } + @Authorized([RIGHTS.SEARCH_USERS]) @Mutation(() => Boolean) async deletePendingCreation(@Arg('id') id: number): Promise { const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository) @@ -147,11 +133,17 @@ export class AdminResolver { return !!res } + @Authorized([RIGHTS.SEARCH_USERS]) @Mutation(() => Boolean) - async confirmPendingCreation(@Arg('id') id: number): Promise { + async confirmPendingCreation(@Arg('id') id: number, @Ctx() context: any): Promise { const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository) const pendingCreation = await loginPendingTasksAdminRepository.findOneOrFail(id) + const userRepository = getCustomRepository(UserRepository) + const moderatorUser = await userRepository.findByPubkeyHex(context.pubKey) + if (moderatorUser.id === pendingCreation.userId) + throw new Error('Moderator can not confirm own pending creation') + const transactionRepository = getCustomRepository(TransactionRepository) const receivedCallDate = new Date() let transaction = new Transaction() diff --git a/frontend/src/main.js b/frontend/src/main.js index cbd7383aa..edc9e575e 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -30,6 +30,13 @@ loadAllRules(i18n) addNavigationGuards(router, store, apolloProvider.defaultClient) +if (!store) { + setTimeout( + window.location.assign('https://github.com/gradido/gradido/tree/master/support#cookies'), + 5000, + ) +} + /* eslint-disable no-new */ new Vue({ el: '#app', diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index c49197059..d219ecacd 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -78,32 +78,41 @@ export const actions = { }, } -export const store = new Vuex.Store({ - plugins: [ - createPersistedState({ - storage: window.localStorage, - }), - ], - state: { - email: '', - language: null, - firstName: '', - lastName: '', - username: '', - description: '', - token: null, - isAdmin: false, - coinanimation: true, - newsletterState: null, - community: { - name: '', +let store + +try { + store = new Vuex.Store({ + plugins: [ + createPersistedState({ + storage: window.localStorage, + }), + ], + state: { + email: '', + language: null, + firstName: '', + lastName: '', + username: '', description: '', + token: null, + isAdmin: false, + coinanimation: true, + newsletterState: null, + community: { + name: '', + description: '', + }, + hasElopage: false, + publisherId: null, }, - hasElopage: false, - publisherId: null, - }, - getters: {}, - // Syncronous mutation of the state - mutations, - actions, -}) + getters: {}, + // Syncronous mutation of the state + mutations, + actions, + }) +} catch (error) { + // eslint-disable-next-line no-console + console.log(error) +} + +export { store } diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index 4f25f5352..41a0540be 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -1,4 +1,8 @@ import { mutations, actions } from './store' +import Vuex from 'vuex' +import Vue from 'vue' + +jest.mock('vuex') const { language, @@ -298,4 +302,25 @@ describe('Vuex store', () => { }) }) }) + + describe('creation of store fails', () => { + const consoleErrorMock = jest.fn() + const warnHandler = Vue.config.warnHandler + beforeEach(() => { + Vue.config.warnHandler = (w) => {} + // eslint-disable-next-line no-console + console.error = consoleErrorMock + Vuex.Store = () => { + throw new Error('no-cookies-allowed') + } + }) + + afterEach(() => { + Vue.config.warnHandler = warnHandler + }) + + it.skip('logs an error message', () => { + expect(consoleErrorMock).toBeCalledWith('no-cookies-allowed') + }) + }) }) diff --git a/support/README.md b/support/README.md new file mode 100644 index 000000000..ba10edb46 --- /dev/null +++ b/support/README.md @@ -0,0 +1,6 @@ +## Cookies + +Die Gradido Wallet benötigt Zugriff auf die local strorage des +Browsers. Bitte stelle sicher, dass in deinem Browser Cookies für die +Gradido Wallet erlaubt sind. +