Skip to content

Commit

Permalink
Updates to use scope type service instead of seedFile object
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzlamateen committed Oct 12, 2023
1 parent 8efd6f9 commit 539ac5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<IdentityProviderQuery> {
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions packages/server-core/src/util/make-initial-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 539ac5a

Please sign in to comment.