mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
Merge branch 'master' into montreal_user_location
This commit is contained in:
commit
66d83455e7
23
backend/src/apis/humhub/model/AbstractUser.ts
Normal file
23
backend/src/apis/humhub/model/AbstractUser.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { User } from '@entity/User'
|
||||
|
||||
import { PublishNameLogic } from '@/data/PublishName.logic'
|
||||
import { PublishNameType } from '@/graphql/enum/PublishNameType'
|
||||
|
||||
import { Account } from './Account'
|
||||
import { Profile } from './Profile'
|
||||
|
||||
export abstract class AbstractUser {
|
||||
public constructor(user: User) {
|
||||
this.account = new Account(user)
|
||||
this.profile = new Profile(user)
|
||||
// temp fix for prevent double usernames in humhub, if the username ist created from initials
|
||||
const publishNameLogic = new PublishNameLogic(user)
|
||||
if (publishNameLogic.isUsernameFromInitials(user.humhubPublishName as PublishNameType)) {
|
||||
this.profile.firstname = this.account.username
|
||||
this.account.username = user.gradidoID
|
||||
}
|
||||
}
|
||||
|
||||
account: Account
|
||||
profile: Profile
|
||||
}
|
||||
@ -1,19 +1,15 @@
|
||||
import { User } from '@entity/User'
|
||||
|
||||
import { Account } from './Account'
|
||||
import { Profile } from './Profile'
|
||||
import { AbstractUser } from './AbstractUser'
|
||||
|
||||
export class GetUser {
|
||||
export class GetUser extends AbstractUser {
|
||||
public constructor(user: User, id: number) {
|
||||
super(user)
|
||||
this.id = id
|
||||
this.account = new Account(user)
|
||||
this.profile = new Profile(user)
|
||||
}
|
||||
|
||||
id: number
|
||||
guid: string
|
||||
// eslint-disable-next-line camelcase
|
||||
display_name: string
|
||||
account: Account
|
||||
profile: Profile
|
||||
}
|
||||
|
||||
@ -1,16 +1,7 @@
|
||||
import { User } from '@entity/User'
|
||||
|
||||
import { Account } from './Account'
|
||||
import { AbstractUser } from './AbstractUser'
|
||||
import { Password } from './Password'
|
||||
import { Profile } from './Profile'
|
||||
|
||||
export class PostUser {
|
||||
public constructor(user: User) {
|
||||
this.account = new Account(user)
|
||||
this.profile = new Profile(user)
|
||||
}
|
||||
|
||||
account: Account
|
||||
profile: Profile
|
||||
// only add password as filed, rest the same as AbstractUser
|
||||
export class PostUser extends AbstractUser {
|
||||
password: Password
|
||||
}
|
||||
|
||||
@ -67,17 +67,25 @@ export class PublishNameLogic {
|
||||
* 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.filterOutInvalidChar(this.user.alias)
|
||||
: this.firstUpperCaseSecondLowerCase(this.filterOutInvalidChar(this.user.firstName)) +
|
||||
this.firstUpperCaseSecondLowerCase(this.filterOutInvalidChar(this.user.lastName))
|
||||
if (this.isUsernameFromInitials(publishNameType)) {
|
||||
return this.filterOutInvalidChar(
|
||||
this.firstUpperCaseSecondLowerCase(this.user.firstName) +
|
||||
this.firstUpperCaseSecondLowerCase(this.user.lastName),
|
||||
)
|
||||
} else if (this.isUsernameFromAlias(publishNameType)) {
|
||||
return this.filterOutInvalidChar(this.user.alias)
|
||||
}
|
||||
return this.hasAlias() ? this.user.alias : this.user.gradidoID
|
||||
return this.user.gradidoID
|
||||
}
|
||||
|
||||
public isUsernameFromInitials(publishNameType: PublishNameType): boolean {
|
||||
return (
|
||||
PublishNameType.PUBLISH_NAME_INITIALS === publishNameType ||
|
||||
(PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && !this.hasAlias())
|
||||
)
|
||||
}
|
||||
|
||||
public isUsernameFromAlias(publishNameType: PublishNameType): boolean {
|
||||
return PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType && this.hasAlias()
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +112,7 @@ beforeAll(async () => {
|
||||
mutate = testEnv.mutate
|
||||
query = testEnv.query
|
||||
con = testEnv.con
|
||||
CONFIG.HUMHUB_ACTIVE = false
|
||||
await cleanDB()
|
||||
})
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import { UserLocationResult } from '@model/UserLocationResult'
|
||||
|
||||
import { HumHubClient } from '@/apis/humhub/HumHubClient'
|
||||
import { GetUser } from '@/apis/humhub/model/GetUser'
|
||||
import { PostUser } from '@/apis/humhub/model/PostUser'
|
||||
import { subscribe } from '@/apis/KlicktippController'
|
||||
import { encode } from '@/auth/JWT'
|
||||
import { RIGHTS } from '@/auth/RIGHTS'
|
||||
@ -169,9 +170,9 @@ export class UserResolver {
|
||||
let humhubUserPromise: Promise<IRestResponse<GetUser>> | undefined
|
||||
const klicktippStatePromise = getKlicktippState(dbUser.emailContact.email)
|
||||
if (CONFIG.HUMHUB_ACTIVE && dbUser.humhubAllowed) {
|
||||
const publishNameLogic = new PublishNameLogic(dbUser)
|
||||
const getHumhubUser = new PostUser(dbUser)
|
||||
humhubUserPromise = HumHubClient.getInstance()?.userByUsernameAsync(
|
||||
publishNameLogic.getUsername(dbUser.humhubPublishName as PublishNameType),
|
||||
getHumhubUser.account.username,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ describe('GdtTransactionList', () => {
|
||||
it('emits input event after currentPage changes', async () => {
|
||||
await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('update:modelValue', 2)
|
||||
await nextTick()
|
||||
expect(wrapper.emitted('input')).toEqual([[2]])
|
||||
expect(wrapper.emitted('update:modelValue')).toEqual([[2]])
|
||||
})
|
||||
|
||||
describe('pagination buttons', () => {
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
</div>
|
||||
<BPagination
|
||||
v-if="transactionGdtCount > pageSize"
|
||||
:model-value="currentPage"
|
||||
v-model="currentPage"
|
||||
class="mt-3"
|
||||
pills
|
||||
size="lg"
|
||||
@ -37,7 +37,6 @@
|
||||
:total-rows="transactionGdtCount"
|
||||
align="center"
|
||||
:hide-ellipsis="true"
|
||||
@update:model-value="currentPage = $event"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -61,13 +60,16 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentPage: this.value,
|
||||
currentPage: this.modelValue,
|
||||
link: 'https://gradido.net/' + this.$store.state.language + '/memberships/',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
currentPage() {
|
||||
if (this.modelValue !== this.currentPage) this.$emit('input', this.currentPage)
|
||||
modelValue(newValue) {
|
||||
this.currentPage = newValue
|
||||
},
|
||||
currentPage(newValue) {
|
||||
if (this.modelValue !== newValue) this.$emit('update:modelValue', newValue)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user