mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
user must delete account on humhub
This commit is contained in:
parent
a869d147e2
commit
d089146fe4
@ -1,6 +1,6 @@
|
||||
import { User } from '@entity/User'
|
||||
import { SignJWT } from 'jose'
|
||||
import { IRequestOptions, RestClient } from 'typed-rest-client'
|
||||
import { IRequestOptions, IRestResponse, RestClient } from 'typed-rest-client'
|
||||
|
||||
import { CONFIG } from '@/config'
|
||||
import { LogError } from '@/server/LogError'
|
||||
@ -104,6 +104,11 @@ export class HumHubClient {
|
||||
return response.result
|
||||
}
|
||||
|
||||
public async userByEmailAsync(email: string): Promise<IRestResponse<GetUser>> {
|
||||
const options = await this.createRequestOptions({ email })
|
||||
return this.restClient.get<GetUser>('/api/v1/user/get-by-email', options)
|
||||
}
|
||||
|
||||
/**
|
||||
* get user by username
|
||||
* https://marketplace.humhub.com/module/rest/docs/html/user.html#tag/User/paths/~1user~1get-by-username/get
|
||||
|
||||
@ -17,6 +17,7 @@ function accountIsTheSame(account: Account, user: User): boolean {
|
||||
if (account.username !== gradidoUserAccount.username) return false
|
||||
if (account.email !== gradidoUserAccount.email) return false
|
||||
if (account.language !== gradidoUserAccount.language) return false
|
||||
if (account.status !== gradidoUserAccount.status) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@ -13,9 +13,11 @@ export class Account {
|
||||
|
||||
this.email = user.emailContact.email
|
||||
this.language = convertGradidoLanguageToHumhub(user.language)
|
||||
this.status = 1
|
||||
}
|
||||
|
||||
username: string
|
||||
email: string
|
||||
language: string
|
||||
status: number
|
||||
}
|
||||
|
||||
@ -82,6 +82,8 @@ import { setUserRole, deleteUserRole } from './util/modifyUserRole'
|
||||
import { sendUserToGms } from './util/sendUserToGms'
|
||||
import { syncHumhub } from './util/syncHumhub'
|
||||
import { validateAlias } from './util/validateAlias'
|
||||
import { GetUser } from '@/apis/humhub/model/GetUser'
|
||||
import { IRestResponse } from 'typed-rest-client'
|
||||
|
||||
const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl']
|
||||
const DEFAULT_LANGUAGE = 'de'
|
||||
@ -144,6 +146,10 @@ export class UserResolver {
|
||||
@Args() { email, password, publisherId }: UnsecureLoginArgs,
|
||||
@Ctx() context: Context,
|
||||
): Promise<User> {
|
||||
let humhubUserPromise: Promise<IRestResponse<GetUser>> | undefined
|
||||
if (CONFIG.HUMHUB_ACTIVE && HumHubClient.getInstance()) {
|
||||
humhubUserPromise = HumHubClient.getInstance()?.userByEmailAsync(email)
|
||||
}
|
||||
logger.info(`login with ${email}, ***, ${publisherId} ...`)
|
||||
email = email.trim().toLowerCase()
|
||||
const dbUser = await findUserByEmail(email)
|
||||
@ -192,6 +198,11 @@ export class UserResolver {
|
||||
})
|
||||
|
||||
await EVENT_USER_LOGIN(dbUser)
|
||||
// load humhub state
|
||||
if (CONFIG.HUMHUB_ACTIVE && user.humhubAllowed) {
|
||||
const result = await humhubUserPromise
|
||||
user.humhubAllowed = result?.result?.account.status === 1
|
||||
}
|
||||
logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`)
|
||||
return user
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="form-user-switch">
|
||||
<div class="form-user-switch" @click="onClick">
|
||||
<b-form-checkbox
|
||||
test="BFormCheckbox"
|
||||
v-model="value"
|
||||
@ -21,6 +21,7 @@ export default {
|
||||
enabledText: { type: String },
|
||||
disabledText: { type: String },
|
||||
disabled: { type: Boolean, default: false },
|
||||
notAllowedText: { type: String, default: undefined },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -47,6 +48,11 @@ export default {
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
onClick() {
|
||||
if (this.notAllowedText && this.disabled) {
|
||||
this.toastError(this.notAllowedText)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -331,7 +331,8 @@
|
||||
"hideAmountGDD": "Dein GDD Betrag ist versteckt.",
|
||||
"hideAmountGDT": "Dein GDT Betrag ist versteckt.",
|
||||
"humhub": {
|
||||
"disabled": "Daten werden nicht in die Gradido Community exportiert",
|
||||
"delete-disabled": "Das Benutzerkonto kann nur im Profil-Menü der Kooperationsplattform gelöscht werden.",
|
||||
"disabled": "Daten werden nicht in die Gradido Community exportiert",
|
||||
"enabled": "Daten werden in die Gradido Community exportiert",
|
||||
"naming-format": "Namen anzeigen:",
|
||||
"publish-name": {
|
||||
|
||||
@ -331,6 +331,7 @@
|
||||
"hideAmountGDD": "Your GDD amount is hidden.",
|
||||
"hideAmountGDT": "Your GDT amount is hidden.",
|
||||
"humhub": {
|
||||
"delete-disabled": "The user account can only be deleted in the profile menu of the cooperation platform.",
|
||||
"disabled": "Data not exported into the Gradido Community",
|
||||
"enabled": "Data exported into the Gradido Community",
|
||||
"naming-format": "Show Name:",
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
<div v-if="isCommunityService">
|
||||
<b-tab :title="$t('settings.community')">
|
||||
<div class="h2">{{ $t('settings.allow-community-services') }}</div>
|
||||
<div v-if="isHumhub" class="mt-4">
|
||||
<div v-if="isHumhub" class="">
|
||||
<b-row>
|
||||
<b-col cols="12" md="6" lg="6">
|
||||
<div class="h3">{{ $t('Humhub.title') }}</div>
|
||||
@ -92,13 +92,15 @@
|
||||
@valueChanged="humhubStateSwitch"
|
||||
:initialValue="$store.state.humhubAllowed"
|
||||
:attrName="'humhubAllowed'"
|
||||
:disabled="isHumhubActivated"
|
||||
:enabledText="$t('settings.humhub.enabled')"
|
||||
:disabledText="$t('settings.humhub.disabled')"
|
||||
:notAllowedText="$t('settings.humhub.delete-disabled')"
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div class="h4">{{ $t('Humhub.desc') }}</div>
|
||||
<b-row v-if="humhubAllowed" class="mt-4 humhub-publish-name-row">
|
||||
<b-row v-if="humhubAllowed" class="mb-4 humhub-publish-name-row">
|
||||
<b-col cols="12" md="6" lg="6">
|
||||
{{ $t('settings.humhub.naming-format') }}
|
||||
</b-col>
|
||||
@ -127,7 +129,7 @@
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div class="h4 mb-3">{{ $t('GMS.desc') }}</div>
|
||||
<div class="h4 mt-3">{{ $t('GMS.desc') }}</div>
|
||||
<div v-if="gmsAllowed">
|
||||
<b-row class="mb-4">
|
||||
<b-col cols="12" md="6" lg="6">
|
||||
@ -238,6 +240,9 @@ export default {
|
||||
const { firstName, lastName } = this.$store.state
|
||||
return firstName === this.firstName && lastName === this.lastName
|
||||
},
|
||||
isHumhubActivated() {
|
||||
return this.humhubAllowed
|
||||
},
|
||||
isCommunityService() {
|
||||
return this.isGMS || this.isHumhub
|
||||
},
|
||||
@ -282,9 +287,6 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.humhub-publish-name-row {
|
||||
min-height: 210px;
|
||||
}
|
||||
.card-border-radius {
|
||||
border-radius: 0px 5px 5px 0px !important;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user