@@ -32,17 +32,15 @@ import { createAsyncOnlyMongoCollection, createAsyncOnlyReadOnlyMongoCollection
3232import { ObserveChangesForHash } from './lib'
3333import { logger } from '../logging'
3434import { allowOnlyFields , rejectFields } from '../security/allowDeny'
35- import { checkUserIdHasOneOfPermissions } from '../security/auth'
3635import { DBNotificationObj } from '@sofie-automation/corelib/dist/dataModel/Notifications'
3736
3837export * from './bucket'
3938export * from './packages-media'
4039export * from './rundown'
4140
4241export const Blueprints = createAsyncOnlyMongoCollection < Blueprint > ( CollectionName . Blueprints , {
43- update ( userId , doc , fields , _modifier ) {
44- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Blueprints , 'configure' ) ) return false
45-
42+ requiredPermissions : [ 'configure' ] ,
43+ update ( _permissions , doc , fields , _modifier ) {
4644 return allowOnlyFields ( doc , fields , [ 'name' , 'disableVersionChecks' ] )
4745 } ,
4846} )
@@ -51,9 +49,8 @@ registerIndex(Blueprints, {
5149} )
5250
5351export const CoreSystem = createAsyncOnlyMongoCollection < ICoreSystem > ( CollectionName . CoreSystem , {
54- async update ( userId , doc , fields , _modifier ) {
55- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . CoreSystem , 'configure' ) ) return false
56-
52+ requiredPermissions : [ 'configure' ] ,
53+ async update ( _permissions , doc , fields , _modifier ) {
5754 return allowOnlyFields ( doc , fields , [
5855 'systemInfo' ,
5956 'name' ,
@@ -110,9 +107,8 @@ registerIndex(Notifications, {
110107} )
111108
112109export const Organizations = createAsyncOnlyMongoCollection < DBOrganization > ( CollectionName . Organizations , {
113- async update ( userId , doc , fields , _modifier ) {
114- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Organizations , 'configure' ) ) return false
115-
110+ requiredPermissions : [ 'configure' ] ,
111+ async update ( _permissions , doc , fields , _modifier ) {
116112 return allowOnlyFields ( doc , fields , [ 'userRoles' ] )
117113 } ,
118114} )
@@ -126,9 +122,8 @@ registerIndex(PeripheralDeviceCommands, {
126122} )
127123
128124export const PeripheralDevices = createAsyncOnlyMongoCollection < PeripheralDevice > ( CollectionName . PeripheralDevices , {
129- update ( userId , doc , fields , _modifier ) {
130- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . PeripheralDevices , 'configure' ) ) return false
131-
125+ requiredPermissions : [ 'configure' ] ,
126+ update ( _permissions , doc , fields , _modifier ) {
132127 return allowOnlyFields ( doc , fields , [
133128 'name' ,
134129 'deviceName' ,
@@ -151,9 +146,8 @@ registerIndex(PeripheralDevices, {
151146} )
152147
153148export const RundownLayouts = createAsyncOnlyMongoCollection < RundownLayoutBase > ( CollectionName . RundownLayouts , {
154- async update ( userId , doc , fields ) {
155- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . RundownLayouts , 'configure' ) ) return false
156-
149+ requiredPermissions : [ 'configure' ] ,
150+ async update ( _permissions , doc , fields ) {
157151 return rejectFields ( doc , fields , [ '_id' , 'showStyleBaseId' ] )
158152 } ,
159153} )
@@ -168,9 +162,8 @@ registerIndex(RundownLayouts, {
168162} )
169163
170164export const ShowStyleBases = createAsyncOnlyMongoCollection < DBShowStyleBase > ( CollectionName . ShowStyleBases , {
171- async update ( userId , doc , fields ) {
172- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . ShowStyleBases , 'configure' ) ) return false
173-
165+ requiredPermissions : [ 'configure' ] ,
166+ async update ( _permissions , doc , fields ) {
174167 return rejectFields ( doc , fields , [ '_id' ] )
175168 } ,
176169} )
@@ -179,9 +172,8 @@ registerIndex(ShowStyleBases, {
179172} )
180173
181174export const ShowStyleVariants = createAsyncOnlyMongoCollection < DBShowStyleVariant > ( CollectionName . ShowStyleVariants , {
182- async update ( userId , doc , fields ) {
183- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . ShowStyleVariants , 'configure' ) ) return false
184-
175+ requiredPermissions : [ 'configure' ] ,
176+ async update ( _permissions , doc , fields ) {
185177 return rejectFields ( doc , fields , [ 'showStyleBaseId' ] )
186178 } ,
187179} )
@@ -191,9 +183,8 @@ registerIndex(ShowStyleVariants, {
191183} )
192184
193185export const Snapshots = createAsyncOnlyMongoCollection < SnapshotItem > ( CollectionName . Snapshots , {
194- update ( userId , doc , fields , _modifier ) {
195- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Snapshots , 'configure' ) ) return false
196-
186+ requiredPermissions : [ 'configure' ] ,
187+ update ( _permissions , doc , fields , _modifier ) {
197188 return allowOnlyFields ( doc , fields , [ 'comment' ] )
198189 } ,
199190} )
@@ -205,9 +196,8 @@ registerIndex(Snapshots, {
205196} )
206197
207198export const Studios = createAsyncOnlyMongoCollection < DBStudio > ( CollectionName . Studios , {
208- async update ( userId , doc , fields , _modifier ) {
209- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Studios , 'configure' ) ) return false
210-
199+ requiredPermissions : [ 'configure' ] ,
200+ async update ( _permissions , doc , fields , _modifier ) {
211201 return rejectFields ( doc , fields , [ '_id' ] )
212202 } ,
213203} )
@@ -234,9 +224,8 @@ export const TranslationsBundles = createAsyncOnlyMongoCollection<TranslationsBu
234224)
235225
236226export const TriggeredActions = createAsyncOnlyMongoCollection < DBTriggeredActions > ( CollectionName . TriggeredActions , {
237- async update ( userId , doc , fields ) {
238- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . TriggeredActions , 'configure' ) ) return false
239-
227+ requiredPermissions : [ 'configure' ] ,
228+ async update ( _permissions , doc , fields ) {
240229 return rejectFields ( doc , fields , [ '_id' ] )
241230 } ,
242231} )
0 commit comments