mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
remove change, parameter is neccessary for using is also for gms
This commit is contained in:
parent
da6bdfaa61
commit
0ad93ebbf4
@ -3,11 +3,12 @@ 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) {
|
||||
const publishNameLogic = new PublishNameLogic(user)
|
||||
this.username = publishNameLogic.getUsername()
|
||||
this.username = publishNameLogic.getUsername(user.humhubPublishName as PublishNameType)
|
||||
this.email = user.emailContact.email
|
||||
this.language = convertGradidoLanguageToHumhub(user.language)
|
||||
this.status = 1
|
||||
|
||||
@ -9,17 +9,15 @@ describe('test publish name logic', () => {
|
||||
it('alias or initials with alias set', () => {
|
||||
const user = new User()
|
||||
user.alias = 'alias'
|
||||
user.humhubPublishName = PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
const logic = new PublishNameLogic(user)
|
||||
expect(logic.getUsername()).toBe(user.alias)
|
||||
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'
|
||||
user.humhubPublishName = PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
const logic = new PublishNameLogic(user)
|
||||
expect(logic.getUsername()).toBe('JoSm')
|
||||
expect(logic.getUsername(PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS)).toBe('JoSm')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -66,8 +66,7 @@ export class PublishNameLogic {
|
||||
* @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(): string {
|
||||
const publishNameType = this.user.humhubPublishName as PublishNameType
|
||||
public getUsername(publishNameType: PublishNameType): string {
|
||||
if (
|
||||
[
|
||||
PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
|
||||
@ -60,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'
|
||||
@ -171,7 +172,7 @@ export class UserResolver {
|
||||
if (CONFIG.HUMHUB_ACTIVE && dbUser.humhubAllowed) {
|
||||
const publishNameLogic = new PublishNameLogic(dbUser)
|
||||
humhubUserPromise = HumHubClient.getInstance()?.userByUsernameAsync(
|
||||
publishNameLogic.getUsername(),
|
||||
publishNameLogic.getUsername(dbUser.humhubPublishName as PublishNameType),
|
||||
)
|
||||
}
|
||||
|
||||
@ -741,7 +742,7 @@ export class UserResolver {
|
||||
throw new LogError('cannot create humhub client')
|
||||
}
|
||||
const userNameLogic = new PublishNameLogic(dbUser)
|
||||
const username = userNameLogic.getUsername()
|
||||
const username = userNameLogic.getUsername(dbUser.humhubPublishName as PublishNameType)
|
||||
let humhubUser = await humhubClient.userByUsername(username)
|
||||
if (!humhubUser) {
|
||||
humhubUser = await humhubClient.userByEmail(dbUser.emailContact.email)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user