Skip to content

Commit

Permalink
Removed deprecated publication of legacy role assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Sep 5, 2024
1 parent ea42be8 commit c46b2e6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 43 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* BREAKING: Synchronous functions are now available only on client side
* BREAKING: Migration functions for past versions are no longer available
* Removed deprecated publication of legacy role assignments
* UI Helpers now use `console.debug` for debugging messages
* `RolesCollection` and `RoleAssignmentsCollection` can now be exported in addition to being accessed via `Meteor.roles` and `Meteor.roleAssignment`
* Support for Meteor 3
Expand Down
3 changes: 1 addition & 2 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ Package.onUse(function (api) {
api.addFiles('roles/roles_server.js', 'server')
api.addFiles([
'roles/client/debug.js',
'roles/client/uiHelpers.js',
'roles/client/subscriptions.js'
'roles/client/uiHelpers.js'
], 'client')
})

Expand Down
18 changes: 0 additions & 18 deletions roles/client/subscriptions.js

This file was deleted.

8 changes: 6 additions & 2 deletions roles/roles_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,12 @@ Object.assign(Roles, {
_checkScopeName: function (scopeName) {
if (scopeName === null) return

if (!scopeName || typeof scopeName !== 'string' || scopeName.trim() !== scopeName) {
throw new Error('Invalid scope name \'' + scopeName + '\'.')
if (
!scopeName ||
typeof scopeName !== 'string' ||
scopeName.trim() !== scopeName
) {
throw new Error(`Invalid scope name '${scopeName}'.`)
}
}
})
20 changes: 0 additions & 20 deletions roles/roles_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,3 @@ for (const index of indexes) {
indexFnAssignment(index)
}
indexFnRoles({ 'children._id': 1 })

/*
* Publish logged-in user's roles so client-side checks can work.
*
* Use a named publish function so clients can check `ready()` state.
*/
Meteor.publish('_roles', function () {
const loggedInUserId = this.userId
const fields = { roles: 1 }

if (!loggedInUserId) {
this.ready()
return
}

return Meteor.users.find(
{ _id: loggedInUserId },
{ fields }
)
})
2 changes: 1 addition & 1 deletion roles/tests/clientAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../roles_common_async'
chai.use(chaiAsPromised)

const safeInsert = async (collection, data) => {
try {
return await collection.insertAsync(data).catch(e => console.error(e))
await collection.insertAsync(data)
} catch (e) {}
}
Expand Down

0 comments on commit c46b2e6

Please sign in to comment.