adapt-authoring-roles 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -83,7 +83,7 @@ class RolesModule extends AbstractApiModule {
83
83
  async initDefaultRoles () {
84
84
  const rolesforAll = await this.shortNamesToIds(this.getConfig('defaultRoles'))
85
85
  const rolesForAuth = Object.entries(this.getConfig('defaultRolesForAuthTypes')).reduce((m, [k, v]) => {
86
- return { [m[k]]: this.shortNamesToIds(v) }
86
+ return { ...m, [k]: this.shortNamesToIds(v) }
87
87
  }, {})
88
88
  const users = await this.app.waitForModule('users')
89
89
  users.preInsertHook.tap(data => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-roles",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Module for managing user roles",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-roles",
6
6
  "license": "GPL-3.0",
@@ -914,12 +914,6 @@ describe('RolesModule', () => {
914
914
  // ── initDefaultRoles ───────────────────────────────────────────────
915
915
 
916
916
  describe('initDefaultRoles', () => {
917
- // TODO: Bug - initDefaultRoles has a broken reduce in rolesForAuth.
918
- // The reduce accumulator is {}, but the callback uses m[k] as a
919
- // property key (where m is the accumulator). In the first iteration
920
- // m[k] is undefined, so it creates { undefined: Promise }.
921
- // defaultRolesForAuthTypes never works correctly.
922
- // Fix: return { ...m, [k]: this.shortNamesToIds(v) }
923
917
  it('should tap into users preInsertHook', async () => {
924
918
  const tapMock = mock.fn()
925
919
  const usersModule = { preInsertHook: { tap: tapMock } }