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 @@