diff --git a/CHANGELOG.md b/CHANGELOG.md index f07cc6645..73261fb3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [2.0.0](https://github.com/gradido/gradido/compare/1.23.3...2.0.0) +#### [2.0.1](https://github.com/gradido/gradido/compare/2.0.0...2.0.1) +- fix(backend): new local user without communitiyuuid [`#3232`](https://github.com/gradido/gradido/pull/3232) +- fix(frontend): fix to less moderator/admins on information page [`#3230`](https://github.com/gradido/gradido/pull/3230) + +### [2.0.0](https://github.com/gradido/gradido/compare/1.23.3...2.0.0) + +> 31 October 2023 + +- chore(release): v2.0.0 [`#3226`](https://github.com/gradido/gradido/pull/3226) +- feat(frontend): split admins and moderators on info page [`#3222`](https://github.com/gradido/gradido/pull/3222) - feat(federation): x-com-sendcoins 32: communtiy authentication handshake [`#3220`](https://github.com/gradido/gradido/pull/3220) - docs(frontend): update news on wallet start page [`#3221`](https://github.com/gradido/gradido/pull/3221) - feat(backend): x-com-sendcoins 31: insert recipient as foreign user in users table after x com sendcoins [`#3215`](https://github.com/gradido/gradido/pull/3215) diff --git a/admin/package.json b/admin/package.json index f44873ed8..ca26057a5 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "2.0.0", + "version": "2.0.1", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/backend/package.json b/backend/package.json index 1f4ea67af..b25a7dedb 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 25e901491..7ad0271ea 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -12,7 +12,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0073-introduce_foreign_user_in_users_table', + DB_VERSION: '0074-insert_communityuuid in_existing_users', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/graphql/resolver/EmailOptinCodes.test.ts b/backend/src/graphql/resolver/EmailOptinCodes.test.ts index 640faad17..09ad743fe 100644 --- a/backend/src/graphql/resolver/EmailOptinCodes.test.ts +++ b/backend/src/graphql/resolver/EmailOptinCodes.test.ts @@ -8,6 +8,7 @@ import { GraphQLError } from 'graphql' import { testEnvironment, cleanDB } from '@test/helpers' import { CONFIG } from '@/config' +import { writeHomeCommunityEntry } from '@/seeds/community' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { queryOptIn } from '@/seeds/graphql/queries' @@ -46,6 +47,7 @@ describe('EmailOptinCodes', () => { lastName: 'Lustig', language: 'de', } + await writeHomeCommunityEntry() const { data: { createUser: user }, } = await mutate({ mutation: createUser, variables }) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index a9c50553e..e16e0f0fc 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -34,6 +34,7 @@ import { import { EventType } from '@/event/Events' import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils' import { encryptPassword } from '@/password/PasswordEncryptor' +import { writeHomeCommunityEntry } from '@/seeds/community' import { contributionLinkFactory } from '@/seeds/factory/contributionLink' import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { userFactory } from '@/seeds/factory/user' @@ -125,9 +126,11 @@ describe('UserResolver', () => { let result: any let emailVerificationCode: string let user: User[] + let homeCom: DbCommunity beforeAll(async () => { jest.clearAllMocks() + homeCom = await writeHomeCommunityEntry() result = await mutate({ mutation: createUser, variables }) }) @@ -172,7 +175,7 @@ describe('UserResolver', () => { referrerId: null, contributionLinkId: null, passwordEncryptionType: PasswordEncryptionType.NO_PASSWORD, - communityUuid: null, + communityUuid: homeCom.communityUuid, foreign: false, }, ]) @@ -542,6 +545,7 @@ describe('UserResolver', () => { let newUser: User beforeAll(async () => { + await writeHomeCommunityEntry() await mutate({ mutation: createUser, variables: createUserVariables }) const emailContact = await UserContact.findOneOrFail({ where: { email: createUserVariables.email }, @@ -586,6 +590,7 @@ describe('UserResolver', () => { describe('no valid password', () => { beforeAll(async () => { + await writeHomeCommunityEntry() await mutate({ mutation: createUser, variables: createUserVariables }) const emailContact = await UserContact.findOneOrFail({ where: { email: createUserVariables.email }, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 45ccd720e..1f21abbb9 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -275,6 +275,10 @@ export class UserResolver { { id: 0 } as DbUser, ) let dbUser = new DbUser() + const homeCom = await getHomeCommunity() + if (homeCom.communityUuid) { + dbUser.communityUuid = homeCom.communityUuid + } dbUser.gradidoID = gradidoID dbUser.firstName = firstName dbUser.lastName = lastName diff --git a/backend/src/seeds/community/index.ts b/backend/src/seeds/community/index.ts index 6a639ee44..84542e002 100644 --- a/backend/src/seeds/community/index.ts +++ b/backend/src/seeds/community/index.ts @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid' import { CONFIG } from '@/config' -export async function writeHomeCommunityEntry(): Promise { +export async function writeHomeCommunityEntry(): Promise { try { // check for existing homeCommunity entry let homeCom = await DbCommunity.findOne({ where: { foreign: false } }) @@ -28,6 +28,7 @@ export async function writeHomeCommunityEntry(): Promise { homeCom.creationDate = new Date() await DbCommunity.insert(homeCom) } + return homeCom } catch (err) { throw new Error(`Seeding: Error writing HomeCommunity-Entry`) // : ${err}`) } diff --git a/backend/src/seeds/factory/user.ts b/backend/src/seeds/factory/user.ts index 65b0ff3bb..3ddddf336 100644 --- a/backend/src/seeds/factory/user.ts +++ b/backend/src/seeds/factory/user.ts @@ -5,8 +5,8 @@ import { ApolloServerTestClient } from 'apollo-server-testing' import { RoleNames } from '@enum/RoleNames' -import { getHomeCommunity } from '@/graphql/resolver/util/communities' import { setUserRole } from '@/graphql/resolver/util/modifyUserRole' +import { writeHomeCommunityEntry } from '@/seeds/community' import { createUser, setPassword } from '@/seeds/graphql/mutations' import { UserInterface } from '@/seeds/users/UserInterface' @@ -16,6 +16,8 @@ export const userFactory = async ( ): Promise => { const { mutate } = client + const homeCom = await writeHomeCommunityEntry() + const { data: { createUser: { id }, @@ -45,7 +47,6 @@ export const userFactory = async ( await dbUser.save() } try { - const homeCom = await getHomeCommunity() if (homeCom.communityUuid) { dbUser.communityUuid = homeCom.communityUuid await User.save(dbUser) diff --git a/database/migrations/0074-insert_communityuuid in_existing_users.ts b/database/migrations/0074-insert_communityuuid in_existing_users.ts new file mode 100644 index 000000000..11ddf7096 --- /dev/null +++ b/database/migrations/0074-insert_communityuuid in_existing_users.ts @@ -0,0 +1,18 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // read the community uuid of the homeCommunity + const result = await queryFn(`SELECT c.community_uuid from communities as c WHERE c.foreign = 0`) + // and if uuid exists enter the home_community_uuid for all local users + if (result && result[0]) { + await queryFn( + `UPDATE users as u SET u.community_uuid = "${result[0].community_uuid}" WHERE u.foreign = 0 AND u.community_uuid IS NULL`, + ) + } +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // dummy statement to satisfy linter and queryFn + await queryFn('select count(*) from communities') +} diff --git a/database/package.json b/database/package.json index efb310a5a..8916962be 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/dht-node/package.json b/dht-node/package.json index a43c38cf5..b693b746f 100644 --- a/dht-node/package.json +++ b/dht-node/package.json @@ -1,6 +1,6 @@ { "name": "gradido-dht-node", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido dht-node module", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/", diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 2d88e0f92..7aed88ccd 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -4,7 +4,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0073-introduce_foreign_user_in_users_table', + DB_VERSION: '0074-insert_communityuuid in_existing_users', LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info LOG_LEVEL: process.env.LOG_LEVEL || 'info', diff --git a/dlt-connector/package.json b/dlt-connector/package.json index d6d698542..686d6f29b 100644 --- a/dlt-connector/package.json +++ b/dlt-connector/package.json @@ -1,6 +1,6 @@ { "name": "gradido-dlt-connector", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido DLT-Connector", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/", diff --git a/federation/package.json b/federation/package.json index 926453137..e5b8c3e4f 100644 --- a/federation/package.json +++ b/federation/package.json @@ -1,6 +1,6 @@ { "name": "gradido-federation", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido federation module providing Gradido-Hub-Federation and versioned API for inter community communication", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/federation", diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 7cc9ef37e..2770ada06 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0073-introduce_foreign_user_in_users_table', + DB_VERSION: '0074-insert_communityuuid in_existing_users', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/frontend/package.json b/frontend/package.json index b0473f15e..8060beb74 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "2.0.0", + "version": "2.0.1", "private": true, "scripts": { "start": "node run/server.js", diff --git a/package.json b/package.json index ff2475769..b99dcdb66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "2.0.0", + "version": "2.0.1", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git",