Skip to content

Commit

Permalink
Ensure indexes for Roles and Subjects collections as part of boot (#7902
Browse files Browse the repository at this point in the history
)

* Allow DELETE via PATCH/UPDATE operation too

* rollback wrong commit

* Ensure indexes for Roles and Subjects collections as part of boot

---------

Co-authored-by: Milos Kozak <[email protected]>
  • Loading branch information
MarcinJuraszek and MilosKozak authored Feb 26, 2023
1 parent a4d07cd commit 867fc96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/authorization/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ function init (env, ctx) {
, { name: 'activity', permissions: [ 'api:activity:create' ] }
];

storage.ensureIndexes = function ensureIndexes() {
ctx.store.ensureIndexes(rolesCollection, ['name']);
ctx.store.ensureIndexes(subjectsCollection, ['name']);
}

storage.getSHA1 = function getSHA1 (message) {
var shasum = crypto.createHash('sha1');
shasum.update(message);
Expand Down
1 change: 1 addition & 0 deletions lib/server/bootevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function boot (env, language) {
}

ctx.authorization = require('../authorization')(env, ctx);
ctx.authorization.storage.ensureIndexes();
ctx.authorization.storage.reload(function loaded (err) {
if (err) {
ctx.bootErrors = ctx.bootErrors || [ ];
Expand Down

0 comments on commit 867fc96

Please sign in to comment.