Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/js/auth/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ export function validateScopes(scopes: Array<string>): boolean {
return true
}

let valid = false
let valid = true
for (let i = 0; i < scopes.length; i++) {
const scope = scopes[i]
if (VALID_SCOPES[scope] === true) {
valid = true
} else {
return false
const isCollectionScope = scope.indexOf('collection.') === 0
if (!isCollectionScope && VALID_SCOPES[scope] !== true) {
valid = false
}
}
return valid
Expand Down
7 changes: 6 additions & 1 deletion test/auth/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('auth-utils', () => {
})

it('should return false for a scope not on whitelist array', () => {
const scopes = ['illegal_scope']
const scopes = ['illegal_scope', 'store_write']
assert(!validateScopes(scopes))
})

Expand All @@ -33,6 +33,11 @@ describe('auth-utils', () => {
scopes = ['email', 'store_write']
assert(validateScopes(scopes))
})

it('should allow colleciton scopes', () => {
const scopes = ['store_write', 'collection.contact']
assert(validateScopes(scopes))
})
})

describe('appRequestSupportsDirectHub', () => {
Expand Down