mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
adjust configs, add GMS_PLAYGROUND_ROUTE, move export script into apis folder like in humhub
This commit is contained in:
parent
e2a3725679
commit
19720ee6ca
@ -40,6 +40,10 @@ export default defineConfig(async ({ command }) => {
|
|||||||
host: CONFIG.ADMIN_MODULE_HOST, // '0.0.0.0',
|
host: CONFIG.ADMIN_MODULE_HOST, // '0.0.0.0',
|
||||||
port: CONFIG.ADMIN_MODULE_PORT, // 8080,
|
port: CONFIG.ADMIN_MODULE_PORT, // 8080,
|
||||||
},
|
},
|
||||||
|
preview: {
|
||||||
|
host: CONFIG.ADMIN_MODULE_HOST, // '0.0.0.0',
|
||||||
|
port: CONFIG.ADMIN_MODULE_PORT, // 8080,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, './src'),
|
'@': path.resolve(__dirname, './src'),
|
||||||
|
|||||||
@ -16,8 +16,7 @@
|
|||||||
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
|
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
|
||||||
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
|
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
|
||||||
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/executeKlicktipp.ts",
|
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/executeKlicktipp.ts",
|
||||||
"gmsusers": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/gmsUsers.ts",
|
"gmsusers": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/apis/gms/ExportUsers.ts",
|
||||||
"gmsuserList": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/gmsUserList.ts",
|
|
||||||
"humhubUserExport": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/apis/humhub/ExportUsers.ts",
|
"humhubUserExport": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/apis/humhub/ExportUsers.ts",
|
||||||
"locales": "scripts/sort.sh"
|
"locales": "scripts/sort.sh"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
|
|
||||||
import { entities } from '@entity/index'
|
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
// import { createTestClient } from 'apollo-server-testing'
|
// import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
@ -18,6 +17,8 @@ import { LogError } from '@/server/LogError'
|
|||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
CONFIG.EMAIL = false
|
CONFIG.EMAIL = false
|
||||||
|
// use force to copy over all user even if gmsRegistered is set to true
|
||||||
|
const forceMode = process.argv.includes('--force')
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
token: '',
|
token: '',
|
||||||
@ -31,21 +32,6 @@ const context = {
|
|||||||
clientTimezoneOffset: 0,
|
clientTimezoneOffset: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cleanDB = async () => {
|
|
||||||
// this only works as long we do not have foreign key constraints
|
|
||||||
for (const entity of entities) {
|
|
||||||
await resetEntity(entity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const resetEntity = async (entity: any) => {
|
|
||||||
const items = await entity.find({ withDeleted: true })
|
|
||||||
if (items.length > 0) {
|
|
||||||
const ids = items.map((e: any) => e.id)
|
|
||||||
await entity.delete(ids)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const server = await createServer(context)
|
const server = await createServer(context)
|
||||||
// const seedClient = createTestClient(server.apollo)
|
// const seedClient = createTestClient(server.apollo)
|
||||||
@ -59,8 +45,7 @@ const run = async () => {
|
|||||||
const userIds = await DbUser.createQueryBuilder()
|
const userIds = await DbUser.createQueryBuilder()
|
||||||
.select('id')
|
.select('id')
|
||||||
.where({ foreign: false })
|
.where({ foreign: false })
|
||||||
// .andWhere('deleted_at is null')
|
.andWhere('deleted_at is null')
|
||||||
// .andWhere({ gmsRegistered: false })
|
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
logger.debug('userIds:', userIds)
|
logger.debug('userIds:', userIds)
|
||||||
|
|
||||||
@ -73,7 +58,7 @@ const run = async () => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
logger.debug('found local User:', user)
|
logger.debug('found local User:', user)
|
||||||
if (user.gmsAllowed) {
|
if (user.gmsAllowed) {
|
||||||
await sendUserToGms(user, homeCom)
|
await sendUserToGms(user, homeCom, forceMode)
|
||||||
/*
|
/*
|
||||||
const gmsUser = new GmsUser(user)
|
const gmsUser = new GmsUser(user)
|
||||||
try {
|
try {
|
||||||
@ -138,6 +138,7 @@ const gms = {
|
|||||||
// koordinates of Illuminz-instance of GMS
|
// koordinates of Illuminz-instance of GMS
|
||||||
GMS_API_URL: process.env.GMS_API_URL ?? 'http://localhost:4044/',
|
GMS_API_URL: process.env.GMS_API_URL ?? 'http://localhost:4044/',
|
||||||
GMS_DASHBOARD_URL: process.env.GMS_DASHBOARD_URL ?? 'http://localhost:8080/',
|
GMS_DASHBOARD_URL: process.env.GMS_DASHBOARD_URL ?? 'http://localhost:8080/',
|
||||||
|
GMS_PLAYGROUND_ROUTE: process.env.GMS_PLAYGROUND_ROUTE ?? 'usersearch-playground',
|
||||||
// used as secret postfix attached at the gms community-auth-url endpoint ('/hook/gms/' + 'secret')
|
// used as secret postfix attached at the gms community-auth-url endpoint ('/hook/gms/' + 'secret')
|
||||||
GMS_WEBHOOK_SECRET: process.env.GMS_WEBHOOK_SECRET ?? 'secret',
|
GMS_WEBHOOK_SECRET: process.env.GMS_WEBHOOK_SECRET ?? 'secret',
|
||||||
}
|
}
|
||||||
|
|||||||
@ -279,6 +279,13 @@ export const schema = Joi.object({
|
|||||||
.default('http://localhost:8080/')
|
.default('http://localhost:8080/')
|
||||||
.description('The URL for the GMS dashboard'),
|
.description('The URL for the GMS dashboard'),
|
||||||
|
|
||||||
|
GMS_PLAYGROUND_ROUTE: Joi.string()
|
||||||
|
.pattern(/^[\w_-]*$/)
|
||||||
|
.default('usersearch-playground')
|
||||||
|
.description(
|
||||||
|
'gms frontend playground route, playground for standalone playground, usersearch-playground for old',
|
||||||
|
),
|
||||||
|
|
||||||
GMS_WEBHOOK_SECRET: Joi.string()
|
GMS_WEBHOOK_SECRET: Joi.string()
|
||||||
.min(1)
|
.min(1)
|
||||||
.default('secret')
|
.default('secret')
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export async function authenticateGmsUserPlayground(
|
|||||||
const result = new GmsUserAuthenticationResult()
|
const result = new GmsUserAuthenticationResult()
|
||||||
const dashboardUrl = ensureUrlEndsWithSlash(CONFIG.GMS_DASHBOARD_URL)
|
const dashboardUrl = ensureUrlEndsWithSlash(CONFIG.GMS_DASHBOARD_URL)
|
||||||
|
|
||||||
result.url = dashboardUrl.concat('usersearch-playground')
|
result.url = dashboardUrl.concat(CONFIG.GMS_PLAYGROUND_ROUTE)
|
||||||
result.token = await verifyAuthToken(dbUser.communityUuid, token)
|
result.token = await verifyAuthToken(dbUser.communityUuid, token)
|
||||||
logger.info('GmsUserAuthenticationResult:', result)
|
logger.info('GmsUserAuthenticationResult:', result)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -7,14 +7,18 @@ import { CONFIG } from '@/config'
|
|||||||
import { LogError } from '@/server/LogError'
|
import { LogError } from '@/server/LogError'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
export async function sendUserToGms(user: DbUser, homeCom: DbCommunity): Promise<void> {
|
export async function sendUserToGms(
|
||||||
|
user: DbUser,
|
||||||
|
homeCom: DbCommunity,
|
||||||
|
alwaysCreateUser?: boolean,
|
||||||
|
): Promise<void> {
|
||||||
if (homeCom.gmsApiKey === null) {
|
if (homeCom.gmsApiKey === null) {
|
||||||
throw new LogError('HomeCommunity needs GMS-ApiKey to publish user data to GMS.')
|
throw new LogError('HomeCommunity needs GMS-ApiKey to publish user data to GMS.')
|
||||||
}
|
}
|
||||||
logger.debug('User send to GMS:', user)
|
logger.debug('User send to GMS:', user)
|
||||||
const gmsUser = new GmsUser(user)
|
const gmsUser = new GmsUser(user)
|
||||||
try {
|
try {
|
||||||
if (!user.gmsRegistered && user.gmsRegisteredAt === null) {
|
if (alwaysCreateUser === true || (!user.gmsRegistered && user.gmsRegisteredAt === null)) {
|
||||||
logger.debug('create user in gms:', gmsUser)
|
logger.debug('create user in gms:', gmsUser)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) {
|
if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) {
|
||||||
|
|||||||
@ -1,60 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
||||||
|
|
||||||
import { entities } from '@entity/index'
|
|
||||||
// import { createTestClient } from 'apollo-server-testing'
|
|
||||||
|
|
||||||
import { CONFIG } from '@/config'
|
|
||||||
import { createServer } from '@/server/createServer'
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
|
|
||||||
CONFIG.EMAIL = false
|
|
||||||
|
|
||||||
const context = {
|
|
||||||
token: '',
|
|
||||||
setHeaders: {
|
|
||||||
push: (value: { key: string; value: string }): void => {
|
|
||||||
context.token = value.value
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
||||||
forEach: (): void => {},
|
|
||||||
},
|
|
||||||
clientTimezoneOffset: 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const cleanDB = async () => {
|
|
||||||
// this only works as long we do not have foreign key constraints
|
|
||||||
for (const entity of entities) {
|
|
||||||
await resetEntity(entity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const resetEntity = async (entity: any) => {
|
|
||||||
const items = await entity.find({ withDeleted: true })
|
|
||||||
if (items.length > 0) {
|
|
||||||
const ids = items.map((e: any) => e.id)
|
|
||||||
await entity.delete(ids)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const run = async () => {
|
|
||||||
const server = await createServer(context)
|
|
||||||
// const seedClient = createTestClient(server.apollo)
|
|
||||||
const { con } = server
|
|
||||||
|
|
||||||
// test GMS-Api Client
|
|
||||||
try {
|
|
||||||
// const gmsComArray = await communityList()
|
|
||||||
// logger.debug('GMS-Community-List:', gmsComArray)
|
|
||||||
// const gmsUserArray = await userList()
|
|
||||||
// logger.debug('GMS-Community-User-List:', gmsUserArray)
|
|
||||||
} catch (err) {
|
|
||||||
logger.error('Error in GMS-API:', err)
|
|
||||||
}
|
|
||||||
await con.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
void run()
|
|
||||||
@ -48,6 +48,10 @@ export default defineConfig(async ({ command }) => {
|
|||||||
minify: CONFIG.PRODUCTION === true,
|
minify: CONFIG.PRODUCTION === true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
preview: {
|
||||||
|
host: CONFIG.FRONTEND_MODULE_HOST, // '0.0.0.0',
|
||||||
|
port: CONFIG.FRONTEND_MODULE_PORT, // 3000,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, './src'),
|
'@': path.resolve(__dirname, './src'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user