From 539ac5a2364da076aa9bc91832b33caedff11621 Mon Sep 17 00:00:00 2001 From: hanzlamateen Date: Thu, 12 Oct 2023 19:34:16 +0500 Subject: [PATCH] Updates to use scope type service instead of seedFile object --- .../identity-provider/identity-provider.class.ts | 8 ++++++-- .../server-core/src/util/make-initial-admin.ts | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/server-core/src/user/identity-provider/identity-provider.class.ts b/packages/server-core/src/user/identity-provider/identity-provider.class.ts index 7ebb000daa4..06ad6ae0ad8 100755 --- a/packages/server-core/src/user/identity-provider/identity-provider.class.ts +++ b/packages/server-core/src/user/identity-provider/identity-provider.class.ts @@ -44,9 +44,9 @@ import { scopePath, ScopeType } from '@etherealengine/engine/src/schemas/scope/s import { userPath, UserType } from '@etherealengine/engine/src/schemas/user/user.schema' import { Application } from '../../../declarations' +import { scopeTypePath } from '@etherealengine/engine/src/schemas/scope/scope-type.schema' import { KnexAdapterParams } from '@feathersjs/knex' import appConfig from '../../appconfig' -import { scopeTypeSeed } from '../../scope/scope-type/scope-type.seed' import getFreeInviteCode from '../../util/get-free-invite-code' export interface IdentityProviderParams extends KnexAdapterParams { @@ -255,7 +255,11 @@ export class IdentityProviderService< .createAccessToken({}, { subject: result.id.toString() }) } else if (isDev && type === 'admin') { // in dev mode, add all scopes to the first user made an admin - const data = scopeTypeSeed.map(({ type }) => { + const scopeTypes = await this.app.service(scopeTypePath).find({ + paginate: false + }) + + const data = scopeTypes.map(({ type }) => { return { userId, type } }) await this.app.service(scopePath).create(data) diff --git a/packages/server-core/src/util/make-initial-admin.ts b/packages/server-core/src/util/make-initial-admin.ts index e65bb77a464..9379ca540a9 100644 --- a/packages/server-core/src/util/make-initial-admin.ts +++ b/packages/server-core/src/util/make-initial-admin.ts @@ -25,21 +25,25 @@ Ethereal Engine. All Rights Reserved. import { UserID } from '@etherealengine/engine/src/schemas/user/user.schema' -import { ScopeType, scopePath } from '@etherealengine/engine/src/schemas/scope/scope.schema' +import { scopeTypePath } from '@etherealengine/engine/src/schemas/scope/scope-type.schema' +import { scopePath } from '@etherealengine/engine/src/schemas/scope/scope.schema' import { Application } from '../../declarations' -import { scopeTypeSeed } from '../scope/scope-type/scope-type.seed' export default async (app: Application, userId: UserID) => { - const adminCount = (await app.service(scopePath).find({ + const adminCount = await app.service(scopePath).find({ query: { $select: ['id'], type: 'admin:admin' }, paginate: false - })) as ScopeType[] + }) if (adminCount.length === 0) { - const data = scopeTypeSeed.map(({ type }) => { + const scopeTypes = await app.service(scopeTypePath).find({ + paginate: false + }) + + const data = scopeTypes.map(({ type }) => { return { userId, type } }) await app.service(scopePath).create(data)