diff --git a/packages/server/modules/core/tests/generic.spec.js b/packages/server/modules/core/tests/generic.spec.js index 94f4f6733..cce282b0e 100644 --- a/packages/server/modules/core/tests/generic.spec.js +++ b/packages/server/modules/core/tests/generic.spec.js @@ -157,25 +157,23 @@ describe('Generic AuthN & AuthZ controller tests', () => { envHelperMock.resetMockedFunctions() }) it('should allow stream:owners to be stream:owners', async () => { - const role = await authorizeResolver( + await authorizeResolver( serverOwner.id, myStream.id, Roles.Stream.Contributor, null ) - expect(role).to.equal(Roles.Stream.Owner) }) it('should get the passed in role for server:admins if override enabled', async () => { envHelperMock.enable() envHelperMock.mockFunction('adminOverrideEnabled', () => true) - const role = await authorizeResolver( + await authorizeResolver( serverOwner.id, myStream.id, Roles.Stream.Contributor, null ) - expect(role).to.equal(Roles.Stream.Contributor) }) it('should not allow server:admins to be anything if adminOverride is disabled', async () => { try { @@ -195,13 +193,12 @@ describe('Generic AuthN & AuthZ controller tests', () => { envHelperMock.enable() envHelperMock.mockFunction('adminOverrideEnabled', () => true) - const role = await authorizeResolver( + await authorizeResolver( serverOwner.id, notMyStream.id, Roles.Stream.Contributor, null ) - expect(role).to.equal(Roles.Stream.Contributor) }) it('should not allow server:users to be anything if adminOverride is disabled', async () => { diff --git a/packages/server/modules/shared/domain/operations.ts b/packages/server/modules/shared/domain/operations.ts index fd2d8e606..2b316b454 100644 --- a/packages/server/modules/shared/domain/operations.ts +++ b/packages/server/modules/shared/domain/operations.ts @@ -18,7 +18,10 @@ export type GetUserServerRole = (params: { userId: string }) => Promise> -export type ValidateScopes = (scopes: Optional, scope: string) => void +export type ValidateScopes = ( + scopes: Optional, + scope: string +) => Promise export type AuthorizeResolver = ( userId: MaybeNullOrUndefined, diff --git a/packages/server/modules/shared/services/auth.ts b/packages/server/modules/shared/services/auth.ts index c53f7c022..15b95071d 100644 --- a/packages/server/modules/shared/services/auth.ts +++ b/packages/server/modules/shared/services/auth.ts @@ -18,7 +18,7 @@ import { Roles } from '@speckle/shared' /** * Validates the scope against a list of scopes of the current session. */ -export const validateScopesFactory = (): ValidateScopes => (scopes, scope) => { +export const validateScopesFactory = (): ValidateScopes => async (scopes, scope) => { const errMsg = `Your auth token does not have the required scope${ scope?.length ? ': ' + scope + '.' : '.' }`