Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to use scope type service instead of seedFile object #9044

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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