From e49cfa883b78300ace3d310a811dca15ba421a09 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 24 Sep 2024 10:43:55 +0200 Subject: [PATCH 1/6] increase publish name initalien two --- backend/src/data/PublishName.logic.ts | 8 ++++---- frontend/src/locales/de.json | 6 +++--- frontend/src/locales/en.json | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/backend/src/data/PublishName.logic.ts b/backend/src/data/PublishName.logic.ts index e307a74d0..5e3e0e501 100644 --- a/backend/src/data/PublishName.logic.ts +++ b/backend/src/data/PublishName.logic.ts @@ -22,13 +22,13 @@ export class PublishNameLogic { return this.user.firstName } if (PublishNameType.PUBLISH_NAME_INITIALS === publishNameType) { - return this.user.firstName.substring(0, 1) + return this.user.firstName.substring(0, 2) } if (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType) { if (this.user.alias) { return this.user.alias } else { - return this.user.firstName.substring(0, 1) + return this.user.firstName.substring(0, 2) } } return '' @@ -48,12 +48,12 @@ export class PublishNameLogic { publishNameType, ) ) { - return this.user.lastName.substring(0, 1) + return this.user.lastName.substring(0, 2) } else if ( PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && !this.user.alias ) { - return this.user.lastName.substring(0, 1) + return this.user.lastName.substring(0, 2) } return '' diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index e04778830..a4662bdb5 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -376,13 +376,13 @@ }, "publish-name": { "alias-or-initials": "Benutzername oder Initialen", - "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", + "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname jeweils die ersten zwei Buchstaben", "first": "Vorname", "first-tooltip": "Nur der Vornamen", "first-initial": "Vorname und Initial", - "first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens", + "first-initial-tooltip": "Vornamen plus die ersten beiden Anfangsbuchstabe des Nachnamens", "initials": "Initialen", - "initials-tooltip": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens", + "initials-tooltip": "Initialen von Vor- und Nachname also jeweils die ersten zwei Buchstaben unabhängig von der Existenz des Benutzernamens", "name-full": "Vorname und Nachname", "name-full-tooltip": "Vollständiger Name: Vorname plus Nachname" }, diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 2aceda935..e28fe4c9f 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -376,15 +376,15 @@ }, "publish-name": { "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", + "alias-or-initials-tooltip": "username, if available, or the initials of the first name and last name, the first two letters in each case", + "first": "Firstname", + "first-tooltip": "the first name only", + "first-initial": "First name and initial", + "first-initial-tooltip": "first name plus the first two initial letters of the last name", "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" + "initials-tooltip": "Initials of first name and last name, i.e. the first two letters of each regardless of the existence of the user name", + "name-full": "first name and last name", + "name-full-tooltip": "full name: first name plus last name" }, "showAmountGDD": "Your GDD amount is visible.", "showAmountGDT": "Your GDT amount is visible.", From d6b3ce66c3a35b3c2f2911b8480544b61c1d53b1 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 3 Oct 2024 14:07:27 +0200 Subject: [PATCH 2/6] use first character upper case, second character lower case --- backend/src/data/PublishName.logic.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/src/data/PublishName.logic.ts b/backend/src/data/PublishName.logic.ts index 5e3e0e501..3fb9cccfa 100644 --- a/backend/src/data/PublishName.logic.ts +++ b/backend/src/data/PublishName.logic.ts @@ -1,10 +1,18 @@ import { User } from '@entity/User' import { PublishNameType } from '@/graphql/enum/PublishNameType' +import { LogError } from '@/server/LogError' export class PublishNameLogic { constructor(private user: User) {} + private firstUpperCaseSecondLowerCase(substring: string) { + if (substring.length !== 2) { + throw new LogError("substring hasn't expected length of 2") + } + return substring.charAt(0).toUpperCase() + substring.charAt(1).toLocaleLowerCase() + } + /** * get first name based on publishNameType: PublishNameType value * @param publishNameType @@ -22,13 +30,13 @@ export class PublishNameLogic { return this.user.firstName } if (PublishNameType.PUBLISH_NAME_INITIALS === publishNameType) { - return this.user.firstName.substring(0, 2) + return this.user.firstName.substring(0, 1) } if (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType) { if (this.user.alias) { return this.user.alias } else { - return this.user.firstName.substring(0, 2) + return this.firstUpperCaseSecondLowerCase(this.user.firstName.substring(0, 2)) } } return '' @@ -48,12 +56,12 @@ export class PublishNameLogic { publishNameType, ) ) { - return this.user.lastName.substring(0, 2) + return this.user.lastName.substring(0, 1) } else if ( PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && !this.user.alias ) { - return this.user.lastName.substring(0, 2) + return this.firstUpperCaseSecondLowerCase(this.user.lastName.substring(0, 2)) } return '' From e802bac1524cdb77e6c65aa6abfbf90159bcef0d Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 7 Oct 2024 18:50:30 +0200 Subject: [PATCH 3/6] initial and alias and initial --- backend/src/data/PublishName.logic.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/src/data/PublishName.logic.ts b/backend/src/data/PublishName.logic.ts index 3fb9cccfa..2c85f5722 100644 --- a/backend/src/data/PublishName.logic.ts +++ b/backend/src/data/PublishName.logic.ts @@ -30,7 +30,7 @@ export class PublishNameLogic { return this.user.firstName } if (PublishNameType.PUBLISH_NAME_INITIALS === publishNameType) { - return this.user.firstName.substring(0, 1) + return this.firstUpperCaseSecondLowerCase(this.user.firstName.substring(0, 2)) } if (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType) { if (this.user.alias) { @@ -51,15 +51,11 @@ export class PublishNameLogic { public getLastName(publishNameType: PublishNameType): string { if (PublishNameType.PUBLISH_NAME_FULL === publishNameType) { return this.user.lastName - } else if ( - [PublishNameType.PUBLISH_NAME_FIRST_INITIAL, PublishNameType.PUBLISH_NAME_INITIALS].includes( - publishNameType, - ) - ) { + } else if (PublishNameType.PUBLISH_NAME_FIRST_INITIAL === publishNameType) { return this.user.lastName.substring(0, 1) } else if ( - PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && - !this.user.alias + (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && !this.user.alias) || + PublishNameType.PUBLISH_NAME_INITIALS === publishNameType ) { return this.firstUpperCaseSecondLowerCase(this.user.lastName.substring(0, 2)) } From 675b3868a178e91f24debe74784f95c1a684493a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 17 Oct 2024 16:01:41 +0200 Subject: [PATCH 4/6] add test, update code --- backend/src/apis/humhub/model/Account.ts | 10 ++- backend/src/apis/humhub/model/Profile.ts | 5 +- backend/src/data/PublishName.logic.test.ts | 23 ++++++ backend/src/data/PublishName.logic.ts | 81 ++++++++++++---------- 4 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 backend/src/data/PublishName.logic.test.ts diff --git a/backend/src/apis/humhub/model/Account.ts b/backend/src/apis/humhub/model/Account.ts index 1ac30fc98..1eb3e37be 100644 --- a/backend/src/apis/humhub/model/Account.ts +++ b/backend/src/apis/humhub/model/Account.ts @@ -2,15 +2,13 @@ import { User } from '@entity/User' import { convertGradidoLanguageToHumhub } from '@/apis/humhub/convertLanguage' +import { PublishNameLogic } from '@/data/PublishName.logic' +import { PublishNameType } from '@/graphql/enum/PublishNameType' export class Account { public constructor(user: User) { - if (user.alias && user.alias.length > 2) { - this.username = user.alias - } else { - this.username = user.gradidoID - } - + const publishNameLogic = new PublishNameLogic(user) + this.username = publishNameLogic.getUsername(user.humhubPublishName as PublishNameType) this.email = user.emailContact.email this.language = convertGradidoLanguageToHumhub(user.language) this.status = 1 diff --git a/backend/src/apis/humhub/model/Profile.ts b/backend/src/apis/humhub/model/Profile.ts index 336e8cb80..3315378eb 100644 --- a/backend/src/apis/humhub/model/Profile.ts +++ b/backend/src/apis/humhub/model/Profile.ts @@ -10,7 +10,10 @@ export class Profile { const publishNameLogic = new PublishNameLogic(user) this.firstname = publishNameLogic.getFirstName(user.humhubPublishName as PublishNameType) this.lastname = publishNameLogic.getLastName(user.humhubPublishName as PublishNameType) - this.gradido_address = CONFIG.COMMUNITY_NAME + '/' + user.gradidoID + + this.gradido_address = `${CONFIG.COMMUNITY_NAME}/${ + publishNameLogic.hasAlias() ? user.alias : user.gradidoID + }` } firstname: string diff --git a/backend/src/data/PublishName.logic.test.ts b/backend/src/data/PublishName.logic.test.ts new file mode 100644 index 000000000..280836c5e --- /dev/null +++ b/backend/src/data/PublishName.logic.test.ts @@ -0,0 +1,23 @@ +import { User } from '@entity/User' + +import { PublishNameType } from '@/graphql/enum/PublishNameType' + +import { PublishNameLogic } from './PublishName.logic' + +describe('test publish name logic', () => { + describe('test username', () => { + it('alias or initials with alias set', () => { + const user = new User() + user.alias = 'alias' + const logic = new PublishNameLogic(user) + expect(logic.getUsername(PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS)).toBe(user.alias) + }) + it('alias or initials with empty alias', () => { + const user = new User() + user.firstName = 'John' + user.lastName = 'Smith' + const logic = new PublishNameLogic(user) + expect(logic.getUsername(PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS)).toBe('JoSm') + }) + }) +}) diff --git a/backend/src/data/PublishName.logic.ts b/backend/src/data/PublishName.logic.ts index 2c85f5722..0c9102f38 100644 --- a/backend/src/data/PublishName.logic.ts +++ b/backend/src/data/PublishName.logic.ts @@ -7,59 +7,68 @@ export class PublishNameLogic { constructor(private user: User) {} private firstUpperCaseSecondLowerCase(substring: string) { - if (substring.length !== 2) { - throw new LogError("substring hasn't expected length of 2") + if (!substring || substring.length < 2) { + throw new LogError('substring is to small, it need at least two characters', { substring }) } return substring.charAt(0).toUpperCase() + substring.charAt(1).toLocaleLowerCase() } + public hasAlias(): boolean { + if (this.user.alias && this.user.alias.length >= 3) { + return true + } + return false + } + /** * get first name based on publishNameType: PublishNameType value * @param publishNameType * @returns user.firstName for PUBLISH_NAME_FIRST, PUBLISH_NAME_FIRST_INITIAL or PUBLISH_NAME_FULL - * first initial from user.firstName for PUBLISH_NAME_INITIALS or PUBLISH_NAME_INITIAL_LAST */ public getFirstName(publishNameType: PublishNameType): string { - if ( - [ - PublishNameType.PUBLISH_NAME_FIRST, - PublishNameType.PUBLISH_NAME_FIRST_INITIAL, - PublishNameType.PUBLISH_NAME_FULL, - ].includes(publishNameType) - ) { - return this.user.firstName - } - if (PublishNameType.PUBLISH_NAME_INITIALS === publishNameType) { - return this.firstUpperCaseSecondLowerCase(this.user.firstName.substring(0, 2)) - } - if (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType) { - if (this.user.alias) { - return this.user.alias - } else { - return this.firstUpperCaseSecondLowerCase(this.user.firstName.substring(0, 2)) - } - } - return '' + return [ + PublishNameType.PUBLISH_NAME_FIRST, + PublishNameType.PUBLISH_NAME_FIRST_INITIAL, + PublishNameType.PUBLISH_NAME_FULL, + ].includes(publishNameType) + ? this.user.firstName + : '' } /** * get last name based on publishNameType: GmsPublishNameType value * @param publishNameType - * @returns user.lastName for PUBLISH_NAME_LAST, PUBLISH_NAME_INITIAL_LAST, PUBLISH_NAME_FULL - * first initial from user.lastName for PUBLISH_NAME_FIRST_INITIAL, PUBLISH_NAME_INITIALS + * @returns user.lastName for PUBLISH_NAME_LAST, PUBLISH_NAME_FULL + * first initial from user.lastName for PUBLISH_NAME_FIRST_INITIAL */ public getLastName(publishNameType: PublishNameType): string { - if (PublishNameType.PUBLISH_NAME_FULL === publishNameType) { - return this.user.lastName - } else if (PublishNameType.PUBLISH_NAME_FIRST_INITIAL === publishNameType) { - return this.user.lastName.substring(0, 1) - } else if ( - (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && !this.user.alias) || - PublishNameType.PUBLISH_NAME_INITIALS === publishNameType - ) { - return this.firstUpperCaseSecondLowerCase(this.user.lastName.substring(0, 2)) - } + return publishNameType === PublishNameType.PUBLISH_NAME_FULL + ? this.user.lastName + : publishNameType === PublishNameType.PUBLISH_NAME_FIRST_INITIAL + ? this.user.lastName.charAt(0) + : '' + } - return '' + /** + * get username from user.alias for PUBLISH_NAME_ALIAS_OR_INITALS and if user has alias + * get first name first two characters and last name first two characters for PUBLISH_NAME_ALIAS_OR_INITALS + * if no alias or PUBLISH_NAME_INITIALS + * @param publishNameType + * @returns user.alias for publishNameType = PUBLISH_NAME_ALIAS_OR_INITALS and user has alias + * else return user.firstName[0,2] + user.lastName[0,2] for publishNameType = [PUBLISH_NAME_ALIAS_OR_INITALS, PUBLISH_NAME_INITIALS] + */ + public getUsername(publishNameType: PublishNameType): string { + if ( + [ + PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS, + PublishNameType.PUBLISH_NAME_INITIALS, + ].includes(publishNameType) + ) { + return publishNameType === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS && this.hasAlias() + ? this.user.alias + : this.firstUpperCaseSecondLowerCase(this.user.firstName) + + this.firstUpperCaseSecondLowerCase(this.user.lastName) + } + return this.hasAlias() ? this.user.alias : this.user.gradidoID } } From 56acc5846f4f9203eb847008f6fabd1db73cca9f Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 22 Oct 2024 14:07:10 +0200 Subject: [PATCH 5/6] filter invalid humhub chars from username, fix export users --- backend/package.json | 3 ++- backend/src/apis/humhub/ExportUsers.ts | 30 +++++++++++++++----------- backend/src/data/PublishName.logic.ts | 25 ++++++++++++++------- backend/yarn.lock | 25 +++++++++++++++++++++ 4 files changed, 62 insertions(+), 21 deletions(-) diff --git a/backend/package.json b/backend/package.json index ba45225a2..cd01d69d4 100644 --- a/backend/package.json +++ b/backend/package.json @@ -50,7 +50,8 @@ "sodium-native": "^3.3.0", "type-graphql": "^1.1.1", "typed-rest-client": "^1.8.11", - "uuid": "^8.3.2" + "uuid": "^8.3.2", + "xregexp": "^5.1.1" }, "devDependencies": { "@eslint-community/eslint-plugin-eslint-comments": "^3.2.1", diff --git a/backend/src/apis/humhub/ExportUsers.ts b/backend/src/apis/humhub/ExportUsers.ts index 8a40d480d..b3af27f7d 100644 --- a/backend/src/apis/humhub/ExportUsers.ts +++ b/backend/src/apis/humhub/ExportUsers.ts @@ -9,9 +9,11 @@ import { checkDBVersion } from '@/typeorm/DBVersion' import { HumHubClient } from './HumHubClient' import { GetUser } from './model/GetUser' +import { UsersResponse } from './model/UsersResponse' import { ExecutedHumhubAction, syncUser } from './syncUser' const USER_BULK_SIZE = 20 +const HUMHUB_BULK_SIZE = 50 function getUsersPage(page: number, limit: number): Promise<[User[], number]> { return User.findAndCount({ @@ -29,24 +31,28 @@ function getUsersPage(page: number, limit: number): Promise<[User[], number]> { async function loadUsersFromHumHub(client: HumHubClient): Promise> { const start = new Date().getTime() const humhubUsers = new Map() - const firstPage = await client.users(0, 50) - if (!firstPage) { - throw new LogError('not a single user found on humhub, please check config and setup') - } - firstPage.results.forEach((user) => { - humhubUsers.set(user.account.email.trim(), user) - }) - let page = 1 - while (humhubUsers.size < firstPage.total) { - const usersPage = await client.users(page, 50) + let page = 0 + let skippedUsersCount = 0 + let usersPage: UsersResponse | null = null + do { + usersPage = await client.users(page, HUMHUB_BULK_SIZE) if (!usersPage) { throw new LogError('error requesting next users page from humhub') } usersPage.results.forEach((user) => { - humhubUsers.set(user.account.email.trim(), user) + // deleted users have empty emails + if (user.account.email) { + humhubUsers.set(user.account.email.trim(), user) + } else { + skippedUsersCount++ + } }) page++ - } + process.stdout.write( + `load users from humhub: ${humhubUsers.size}/${usersPage.total}, skipped: ${skippedUsersCount}\r`, + ) + } while (usersPage && usersPage.results.length === HUMHUB_BULK_SIZE) + const elapsed = new Date().getTime() - start logger.info('load users from humhub', { total: humhubUsers.size, diff --git a/backend/src/data/PublishName.logic.ts b/backend/src/data/PublishName.logic.ts index 0c9102f38..d3643d633 100644 --- a/backend/src/data/PublishName.logic.ts +++ b/backend/src/data/PublishName.logic.ts @@ -1,16 +1,25 @@ import { User } from '@entity/User' +import XRegExp from 'xregexp' import { PublishNameType } from '@/graphql/enum/PublishNameType' -import { LogError } from '@/server/LogError' export class PublishNameLogic { + // allowed characters for humhub usernames + private usernameRegex: RegExp = XRegExp('[\\p{L}\\d_\\-@\\.]', 'g') + constructor(private user: User) {} - private firstUpperCaseSecondLowerCase(substring: string) { - if (!substring || substring.length < 2) { - throw new LogError('substring is to small, it need at least two characters', { substring }) + private firstUpperCaseSecondLowerCase(name: string) { + if (name && name.length >= 2) { + return name.charAt(0).toUpperCase() + name.charAt(1).toLocaleLowerCase() } - return substring.charAt(0).toUpperCase() + substring.charAt(1).toLocaleLowerCase() + return name + } + + // remove character which are invalid for humhub username + private filterOutInvalidChar(name: string) { + // eslint-disable-next-line import/no-named-as-default-member + return XRegExp.match(name, this.usernameRegex, 'all').join('') } public hasAlias(): boolean { @@ -65,9 +74,9 @@ export class PublishNameLogic { ].includes(publishNameType) ) { return publishNameType === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS && this.hasAlias() - ? this.user.alias - : this.firstUpperCaseSecondLowerCase(this.user.firstName) + - this.firstUpperCaseSecondLowerCase(this.user.lastName) + ? this.filterOutInvalidChar(this.user.alias) + : this.firstUpperCaseSecondLowerCase(this.filterOutInvalidChar(this.user.firstName)) + + this.firstUpperCaseSecondLowerCase(this.filterOutInvalidChar(this.user.lastName)) } return this.hasAlias() ? this.user.alias : this.user.gradidoID } diff --git a/backend/yarn.lock b/backend/yarn.lock index 5c33b1ce8..effdd77f2 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -324,6 +324,14 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" +"@babel/runtime-corejs3@^7.16.5": + version "7.25.7" + resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.25.7.tgz#29ca319b1272e9d78faa3f7ee891d0af63c53aa2" + integrity sha512-gMmIEhg35sXk9Te5qbGp3W9YKrvLt3HV658/d3odWrHSqT0JeG5OzsJWFHRLiOohRyjRsJc/x03DhJm3i8VJxg== + dependencies: + core-js-pure "^3.30.2" + regenerator-runtime "^0.14.0" + "@babel/runtime@^7.21.0": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.5.tgz#8564dd588182ce0047d55d7a75e93921107b57ec" @@ -2340,6 +2348,11 @@ core-js-pure@^3.10.2: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.18.2.tgz#d8cc11d4885ea919f3de776d45e720e4c769d406" integrity sha512-4hMMLUlZhKJKOWbbGD1/VDUxGPEhEoN/T01k7bx271WiBKCvCfkgPzy0IeRS4PB50p6/N1q/SZL4B/TRsTE5bA== +core-js-pure@^3.30.2: + version "3.38.1" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.38.1.tgz#e8534062a54b7221344884ba9b52474be495ada3" + integrity sha512-BY8Etc1FZqdw1glX0XNOq2FDwfrg/VGqoZOZCdaL+UmdaqDwQwYXkMJT4t6In+zfEfOJDcM9T0KdbBeJg8KKCQ== + core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -6165,6 +6178,11 @@ regenerator-runtime@^0.13.11: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + regexp-tree@~0.1.1: version "0.1.27" resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.27.tgz#2198f0ef54518ffa743fe74d983b56ffd631b6cd" @@ -7395,6 +7413,13 @@ xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== +xregexp@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-5.1.1.tgz#6d3fe18819e3143aaf52f9284d34f49a59583ebb" + integrity sha512-fKXeVorD+CzWvFs7VBuKTYIW63YD1e1osxwQ8caZ6o1jg6pDAbABDG54LCIq0j5cy7PjRvGIq6sef9DYPXpncg== + dependencies: + "@babel/runtime-corejs3" "^7.16.5" + xss@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/xss/-/xss-1.0.10.tgz#5cd63a9b147a755a14cb0455c7db8866120eb4d2" From 4e5fd42a7abc7239dbfc8d5018e7c5668ee66307 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 11 Nov 2024 12:08:50 +0100 Subject: [PATCH 6/6] hot fix --- backend/src/graphql/resolver/UserResolver.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 3abb745e8..e31dc4867 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -38,6 +38,7 @@ import { subscribe } from '@/apis/KlicktippController' import { encode } from '@/auth/JWT' import { RIGHTS } from '@/auth/RIGHTS' import { CONFIG } from '@/config' +import { PublishNameLogic } from '@/data/PublishName.logic' import { sendAccountActivationEmail, sendAccountMultiRegistrationEmail, @@ -59,6 +60,7 @@ import { EVENT_ADMIN_USER_DELETE, EVENT_ADMIN_USER_UNDELETE, } from '@/event/Events' +import { PublishNameType } from '@/graphql/enum/PublishNameType' import { isValidPassword } from '@/password/EncryptorUtils' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' import { Context, getUser, getClientTimezoneOffset } from '@/server/context' @@ -168,8 +170,9 @@ export class UserResolver { let humhubUserPromise: Promise> | undefined const klicktippStatePromise = getKlicktippState(dbUser.emailContact.email) if (CONFIG.HUMHUB_ACTIVE && dbUser.humhubAllowed) { + const publishNameLogic = new PublishNameLogic(dbUser) humhubUserPromise = HumHubClient.getInstance()?.userByUsernameAsync( - dbUser.alias ?? dbUser.gradidoID, + publishNameLogic.getUsername(dbUser.humhubPublishName as PublishNameType), ) }