From 1fde80ac780d0d2ad182a95f7a3f942f8c015ce4 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 23 Apr 2024 14:34:36 +0200 Subject: [PATCH 01/20] new link for humhub --- frontend/public/img/svg/social_network.svg | 7 ++++ frontend/src/components/Menu/Sidebar.vue | 4 +++ frontend/src/locales/de.json | 6 ++++ frontend/src/locales/en.json | 6 ++++ frontend/src/pages/SocialNetwork.vue | 38 ++++++++++++++++++++++ frontend/src/routes/routes.js | 8 +++++ 6 files changed, 69 insertions(+) create mode 100644 frontend/public/img/svg/social_network.svg create mode 100644 frontend/src/pages/SocialNetwork.vue diff --git a/frontend/public/img/svg/social_network.svg b/frontend/public/img/svg/social_network.svg new file mode 100644 index 000000000..5deb96d1b --- /dev/null +++ b/frontend/public/img/svg/social_network.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index 227275786..a6b096299 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -32,6 +32,10 @@ {{ $t('navigation.info') }} + + + {{ $t('navigation.social_network') }} + {{ $t('navigation.usersearch') }} diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index da212d379..84e3f2d8c 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -268,6 +268,7 @@ "overview": "Übersicht", "send": "Senden", "settings": "Einstellung", + "social_network": "Kreise", "support": "Support", "transactions": "Transaktionen", "usersearch": "Nutzersuche" @@ -417,6 +418,11 @@ "uppercase": "Großbuchstabe erforderlich." } }, + "social-network": { + "headline": "Gradido Kreise", + "text": "Was soll hier für ein Text rein?", + "button": "Beginne dich zu vernetzen..." + }, "status": "Status", "submitted": "Eingereicht", "success": "Erfolg", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 7bba0d5eb..a1b7cd8d6 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -268,6 +268,7 @@ "overview": "Overview", "send": "Send", "settings": "Settings", + "social_network": "Circle", "support": "Support", "transactions": "Transactions", "usersearch": "Geographical User Search" @@ -417,6 +418,11 @@ "uppercase": "One uppercase letter required." } }, + "social-network": { + "headline": "Gradido Circle", + "text": "Placeholder", + "button": "Start to connect..." + }, "status": "Status", "submitted": "Submitted", "success": "Success", diff --git a/frontend/src/pages/SocialNetwork.vue b/frontend/src/pages/SocialNetwork.vue new file mode 100644 index 000000000..eb2ccbdb2 --- /dev/null +++ b/frontend/src/pages/SocialNetwork.vue @@ -0,0 +1,38 @@ + + diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index d8f85b858..ad819f889 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -88,6 +88,14 @@ const routes = [ pageTitle: 'usersearch', }, }, + { + path: '/social-network', + component: () => import('@/pages/SocialNetwork'), + meta: { + requiresAuth: true, + pageTitle: 'social-network', + }, + }, // { // path: '/storys', // component: () => import('@/pages/TopStorys'), From adaece0efe4ddaea08f47243d5c15bfd6401f181 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 25 Apr 2024 13:15:18 +0200 Subject: [PATCH 02/20] rename to cirlces, route to setting extern service tab from circles if humhubAllowed is false --- backend/src/apis/humhub/HumHubClient.ts | 13 ++++ backend/src/auth/RIGHTS.ts | 1 + backend/src/auth/USER_RIGHTS.ts | 1 + backend/src/graphql/resolver/UserResolver.ts | 9 +++ .../graphql/resolver/util/syncHumhub.test.ts | 4 -- .../svg/{social_network.svg => circles.svg} | 0 frontend/src/components/Menu/Sidebar.vue | 6 +- .../UserSettings/UserSettingsSwitch.vue | 1 - frontend/src/graphql/queries.js | 6 ++ frontend/src/locales/de.json | 5 +- frontend/src/locales/en.json | 5 +- frontend/src/pages/Circles.vue | 65 +++++++++++++++++++ frontend/src/pages/Settings.vue | 11 +++- frontend/src/pages/SocialNetwork.vue | 38 ----------- frontend/src/routes/routes.js | 8 +-- 15 files changed, 116 insertions(+), 57 deletions(-) rename frontend/public/img/svg/{social_network.svg => circles.svg} (100%) create mode 100644 frontend/src/pages/Circles.vue delete mode 100644 frontend/src/pages/SocialNetwork.vue diff --git a/backend/src/apis/humhub/HumHubClient.ts b/backend/src/apis/humhub/HumHubClient.ts index b69944773..596d74597 100644 --- a/backend/src/apis/humhub/HumHubClient.ts +++ b/backend/src/apis/humhub/HumHubClient.ts @@ -8,6 +8,7 @@ import { backendLogger as logger } from '@/server/logger' import { GetUser } from './model/GetUser' import { PostUser } from './model/PostUser' import { UsersResponse } from './model/UsersResponse' +import { User } from '@entity/User' /** * HumHubClient as singleton class @@ -58,6 +59,18 @@ export class HumHubClient { return token } + public static async createAutoLoginUrl(user: User) { + const secret = new TextEncoder().encode(CONFIG.HUMHUB_JWT_KEY) + const username = user.alias ?? user.gradidoID + logger.info(`user ${username} as username for humhub auto-login`) + const token = await new SignJWT({ username }) + .setProtectedHeader({ alg: 'HS256' }) + .setIssuedAt() + .setExpirationTime('2m') + .sign(secret) + return `${CONFIG.HUMHUB_API_URL}user/auth/login?jwt=${token}` + } + /** * Get all users from humhub * https://marketplace.humhub.com/module/rest/docs/html/user.html#tag/User/paths/~1user/get diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index c7a23c13b..579fb7f0e 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -38,6 +38,7 @@ export enum RIGHTS { OPEN_CREATIONS = 'OPEN_CREATIONS', USER = 'USER', GMS_USER_PLAYGROUND = 'GMS_USER_PLAYGROUND', + CIRCLES_AUTO_LOGIN = 'CIRCLES_AUTO_LOGIN', // Moderator SEARCH_USERS = 'SEARCH_USERS', ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION', diff --git a/backend/src/auth/USER_RIGHTS.ts b/backend/src/auth/USER_RIGHTS.ts index 0c56b0d02..d649a0649 100644 --- a/backend/src/auth/USER_RIGHTS.ts +++ b/backend/src/auth/USER_RIGHTS.ts @@ -30,4 +30,5 @@ export const USER_RIGHTS = [ RIGHTS.OPEN_CREATIONS, RIGHTS.USER, RIGHTS.GMS_USER_PLAYGROUND, + RIGHTS.CIRCLES_AUTO_LOGIN, ] diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 33a351730..2c18876a1 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -81,6 +81,7 @@ import { setUserRole, deleteUserRole } from './util/modifyUserRole' import { sendUserToGms } from './util/sendUserToGms' import { syncHumhub } from './util/syncHumhub' import { validateAlias } from './util/validateAlias' +import { HumHubClient } from '@/apis/humhub/HumHubClient' const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl'] const DEFAULT_LANGUAGE = 'de' @@ -703,6 +704,14 @@ export class UserResolver { return result } + @Authorized([RIGHTS.CIRCLES_AUTO_LOGIN]) + @Query(() => String) + async authenticateCirclesAutoLogin(@Ctx() context: Context): Promise { + logger.info(`authenticateCirclesAutoLogin()...`) + const dbUser = getUser(context) + return await HumHubClient.createAutoLoginUrl(dbUser) + } + @Authorized([RIGHTS.SEARCH_ADMIN_USERS]) @Query(() => SearchAdminUsersResult) async searchAdminUsers( diff --git a/backend/src/graphql/resolver/util/syncHumhub.test.ts b/backend/src/graphql/resolver/util/syncHumhub.test.ts index c7b187f23..a5a8a87e4 100644 --- a/backend/src/graphql/resolver/util/syncHumhub.test.ts +++ b/backend/src/graphql/resolver/util/syncHumhub.test.ts @@ -22,10 +22,6 @@ const mockUpdateUserInfosArg = new UpdateUserInfosArgs() const mockHumHubUser = new GetUser(mockUser, 1) describe('syncHumhub', () => { - beforeAll(() => { - // humhubClientMockbBeforeAll() - }) - beforeEach(() => { jest.spyOn(logger, 'debug').mockImplementation() jest.spyOn(logger, 'info').mockImplementation() diff --git a/frontend/public/img/svg/social_network.svg b/frontend/public/img/svg/circles.svg similarity index 100% rename from frontend/public/img/svg/social_network.svg rename to frontend/public/img/svg/circles.svg diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index a6b096299..b1017ec86 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -32,9 +32,9 @@ {{ $t('navigation.info') }} - - - {{ $t('navigation.social_network') }} + + + {{ $t('navigation.circles') }} diff --git a/frontend/src/components/UserSettings/UserSettingsSwitch.vue b/frontend/src/components/UserSettings/UserSettingsSwitch.vue index 8e819cba8..53d0f6df8 100644 --- a/frontend/src/components/UserSettings/UserSettingsSwitch.vue +++ b/frontend/src/components/UserSettings/UserSettingsSwitch.vue @@ -29,7 +29,6 @@ export default { async onChange() { const variables = [] variables[this.attrName] = this.value - this.$apollo .mutate({ mutation: updateUserInfos, diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 696963b78..adb11bc8d 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -28,6 +28,12 @@ export const authenticateGmsUserSearch = gql` } ` +export const authenticateCirclesAutoLogin = gql` + query { + authenticateCirclesAutoLogin + } +` + export const transactionsQuery = gql` query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) { transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) { diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 84e3f2d8c..e1bfd3392 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -268,7 +268,7 @@ "overview": "Übersicht", "send": "Senden", "settings": "Einstellung", - "social_network": "Kreise", + "circles": "Kreise", "support": "Support", "transactions": "Transaktionen", "usersearch": "Nutzersuche" @@ -281,6 +281,7 @@ "overview": "Willkommen {name}", "send": "Sende Gradidos", "settings": "Einstellungen", + "circles": "Gradido Kreise", "transactions": "Deine Transaktionen", "usersearch": "Geografische Nutzersuche" }, @@ -418,7 +419,7 @@ "uppercase": "Großbuchstabe erforderlich." } }, - "social-network": { + "circles": { "headline": "Gradido Kreise", "text": "Was soll hier für ein Text rein?", "button": "Beginne dich zu vernetzen..." diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a1b7cd8d6..09538c8d7 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -268,7 +268,7 @@ "overview": "Overview", "send": "Send", "settings": "Settings", - "social_network": "Circle", + "circles": "Circle", "support": "Support", "transactions": "Transactions", "usersearch": "Geographical User Search" @@ -282,6 +282,7 @@ "send": "Send Gradidos", "settings": "Settings", "transactions": "Your transactions", + "circles": "Gradido Circles", "usersearch": "Geographical User Search" }, "qrCode": "QR Code", @@ -418,7 +419,7 @@ "uppercase": "One uppercase letter required." } }, - "social-network": { + "circles": { "headline": "Gradido Circle", "text": "Placeholder", "button": "Start to connect..." diff --git a/frontend/src/pages/Circles.vue b/frontend/src/pages/Circles.vue new file mode 100644 index 000000000..aa7e810d9 --- /dev/null +++ b/frontend/src/pages/Circles.vue @@ -0,0 +1,65 @@ + + diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index 57fb9dc11..fc4a29ca4 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -1,7 +1,7 @@ - diff --git a/frontend/src/components/UserSettings/UserNamingFormat.spec.js b/frontend/src/components/UserSettings/UserNamingFormat.spec.js index 8ded29ca7..c92cca138 100644 --- a/frontend/src/components/UserSettings/UserNamingFormat.spec.js +++ b/frontend/src/components/UserSettings/UserNamingFormat.spec.js @@ -26,9 +26,9 @@ describe('UserNamingFormat', () => { }, localVue, propsData: { - selectedOption: 'PUBLISH_NAME_NONE', - initialValue: 'PUBLISH_NAME_NONE', - attrName: 'publishName', + selectedOption: 'PUBLISH_NAME_ALIAS_OR_INITALS', + initialValue: 'PUBLISH_NAME_ALIAS_OR_INITALS', + attrName: 'gmsPublishName', successMessage: 'success message', }, }) @@ -40,17 +40,15 @@ describe('UserNamingFormat', () => { it('renders the correct dropdown options', () => { const dropdownItems = wrapper.findAll('.dropdown-item') - expect(dropdownItems.length).toBe(7) + expect(dropdownItems.length).toBe(5) const labels = dropdownItems.wrappers.map((item) => item.text()) expect(labels).toEqual([ - 'settings.publish-name.none', + 'settings.publish-name.alias-or-initials', 'settings.publish-name.initials', 'settings.publish-name.first', 'settings.publish-name.first-initial', - 'settings.publish-name.last', - 'settings.publish-name.last-initial', - 'settings.publish-name.full', + 'settings.publish-name.name-full', ]) }) diff --git a/frontend/src/components/UserSettings/UserNamingFormat.vue b/frontend/src/components/UserSettings/UserNamingFormat.vue index 658f276ca..2879e37e0 100644 --- a/frontend/src/components/UserSettings/UserNamingFormat.vue +++ b/frontend/src/components/UserSettings/UserNamingFormat.vue @@ -20,7 +20,7 @@ import { updateUserInfos } from '@/graphql/mutations' export default { name: 'UserNamingFormat', props: { - initialValue: { type: String, default: 'PUBLISH_NAME_NONE' }, + initialValue: { type: String, default: 'PUBLISH_NAME_ALIAS_OR_INITALS' }, attrName: { type: String }, successMessage: { type: String }, }, @@ -29,9 +29,9 @@ export default { selectedOption: this.initialValue, dropdownOptions: [ { - label: this.$t('settings.publish-name.none'), - title: this.$t('settings.publish-name.none-tooltip'), - value: 'PUBLISH_NAME_NONE', + label: this.$t('settings.publish-name.alias-or-initials'), + title: this.$t('settings.publish-name.alias-or-initials-tooltip'), + value: 'PUBLISH_NAME_ALIAS_OR_INITALS', }, { label: this.$t('settings.publish-name.initials'), @@ -49,18 +49,8 @@ export default { value: 'PUBLISH_NAME_FIRST_INITIAL', }, { - label: this.$t('settings.publish-name.last'), - title: this.$t('settings.publish-name.last-tooltip'), - value: 'PUBLISH_NAME_LAST', - }, - { - label: this.$t('settings.publish-name.last-initial'), - title: this.$t('settings.publish-name.last-initial-tooltip'), - value: 'PUBLISH_NAME_INITIAL_LAST', - }, - { - label: this.$t('settings.publish-name.full'), - title: this.$t('settings.publish-name.full-tooltip'), + label: this.$t('settings.publish-name.name-full'), + title: this.$t('settings.publish-name.name-full-tooltip'), value: 'PUBLISH_NAME_FULL', }, ], diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index efcbcffb3..dd812db4b 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -36,7 +36,7 @@ export const updateUserInfos = gql` $hideAmountGDT: Boolean $gmsAllowed: Boolean $humhubAllowed: Boolean - $gmsPublishName: GmsPublishNameType + $gmsPublishName: PublishNameType $humhubPublishName: PublishNameType $gmsLocation: Location $gmsPublishLocation: GmsPublishLocationType diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 0ea569735..ed55a0990 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -325,16 +325,6 @@ "updated": "Positionstyp für GMS aktualisiert" }, "publish-name": { - "alias-or-initials": "Benutzername oder Initialen", - "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", - "first": "Vorname", - "first-tooltip": "Nur der Vornamen", - "first-initial": "Vorname und Initiale", - "first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens", - "initials": "Initialen", - "initials-tooltip": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens", - "name-full": "Ganzer Name", - "name-full-tooltip": "Vollständiger Name: Vorname plus Nachname", "updated": "Namensformat für GMS aktualisiert" }, "switch": "Erlaubnis Daten nach GMS zu exportieren." @@ -388,20 +378,16 @@ "subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen." }, "publish-name": { - "none": "Keine", - "none-tooltip": "Vorname und Nachname bleiben leer", + "alias-or-initials": "Benutzername oder Initialen (Default)", + "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", "first": "Vorname", - "first-tooltip": "Nur der Vornamen, z.B. Max", - "first-initial": "Vorname und Initiale", - "first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens, z.B. Max M.", - "last": "Nachname", - "last-tooltip": "Nur der Nachname, z.B. Mustermann", - "last-initial": "Initiale und Nachname", - "last-initial-tooltip": "Anfangsbuchstabe des Vornamen plus Nachname, z.B. M. Mustermann", + "first-tooltip": "Nur der Vornamen", + "first-initial": "Vorname und Initial", + "first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens", "initials": "Initialen", - "initials-tooltip": "Nur die Initialen von Vor- und Nachname, z.B. M. M.", - "full": "Ganzer Name", - "full-tooltip": "Vollständiger Name: Vorname plus Nachname, z.B. Max Mustermann" + "initials-tooltip": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens", + "name-full": "Vorname und Nachname", + "name-full-tooltip": "Vollständiger Name: Vorname plus Nachname" }, "showAmountGDD": "Dein GDD Betrag ist sichtbar.", "showAmountGDT": "Dein GDT Betrag ist sichtbar.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4c90732fe..9bd79448a 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -325,16 +325,6 @@ "updated": "format of location for GMS updated" }, "publish-name": { - "alias-or-initials": "Username or initials", - "alias-or-initials-tooltip": "username if exists or Initials of firstname and lastname", - "first": "firstname", - "first-tooltip": "the firstname only", - "first-initial": "firstname and initial", - "first-initial-tooltip": "firstname plus initial of lastname", - "initials": "Initials of firstname and lastname independent if username exists", - "initials-tooltip": "Initials of firstname and lastname independent if username exists", - "name-full": "fullname", - "name-full-tooltip": "fullname: firstname plus lastname", "updated": "format of name for GMS updated" }, "switch": "Allow data export to GMS" @@ -388,20 +378,16 @@ "subtitle": "If you have forgotten your password, you can reset it here." }, "publish-name": { - "none": "None", - "none-tooltip": "first name and last name are empty", - "first": "first name", - "first-tooltip": "the first name only", - "first-initial": "first name and initial", - "first-initial-tooltip": "first name plus initial of last name", - "last": "last name", - "last-tooltip": "last name only", - "last-initial": "initial and last name", - "last-initial-tooltip": "First letter of the first name plus last name", - "initials": "initials", - "initials-tooltip": "Initials of first name and last name", - "full": "full name", - "full-tooltip": "full name: firstname plus lastname" + "alias-or-initials": "Username or initials (Default)", + "alias-or-initials-tooltip": "username if exists or Initials of firstname and lastname", + "first": "firstname", + "first-tooltip": "the firstname only", + "first-initial": "firstname and initial", + "first-initial-tooltip": "firstname plus initial of lastname", + "initials": "Initials", + "initials-tooltip": "Initials of firstname and lastname independent if username exists", + "name-full": "firstname and lastname", + "name-full-tooltip": "fullname: firstname plus lastname" }, "showAmountGDD": "Your GDD amount is visible.", "showAmountGDT": "Your GDT amount is visible.", diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index 94f10f018..14a1df920 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -108,7 +108,7 @@ {{ $t('settings.GMS.naming-format') }} - - + {{ $t('settings.humhub.naming-format') }} @@ -182,7 +182,6 @@