-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration 030-add-read-system-info-permissions
- Loading branch information
1 parent
aa6a4c2
commit ae3d0c9
Showing
3 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
service/src/migrations/030-add-read-system-info-permissions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const mongoose = require('mongoose'); | ||
const RoleModel = mongoose.model('Role'); | ||
|
||
exports.id = 'add-read-system-info-permission'; | ||
|
||
exports.up = function(done) { | ||
this.log('adding READ_SYSTEM_INFO permission to ADMIN_ROLE ...'); | ||
|
||
// Use $addToSet to ensure the permission is only added if it doesn't exist | ||
RoleModel.updateOne( | ||
{ name: 'ADMIN_ROLE' }, | ||
{ $addToSet: { permissions: 'READ_SYSTEM_INFO' } }, | ||
function(err) { | ||
done(err); | ||
} | ||
); | ||
}; | ||
|
||
exports.down = function(done) { | ||
this.log('removing READ_SYSTEM_INFO permission from ADMIN_ROLE ...'); | ||
|
||
RoleModel.updateOne( | ||
{ name: 'ADMIN_ROLE' }, | ||
{ $pull: { permissions: 'READ_SYSTEM_INFO' } }, | ||
function(err) { | ||
done(err); | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters