@@ -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' ,
@@ -111,9 +108,8 @@ registerIndex(Notifications, {
111108} )
112109
113110export const Organizations = createAsyncOnlyMongoCollection < DBOrganization > ( CollectionName . Organizations , {
114- async update ( userId , doc , fields , _modifier ) {
115- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Organizations , 'configure' ) ) return false
116-
111+ requiredPermissions : [ 'configure' ] ,
112+ async update ( _permissions , doc , fields , _modifier ) {
117113 return allowOnlyFields ( doc , fields , [ 'userRoles' ] )
118114 } ,
119115} )
@@ -127,9 +123,8 @@ registerIndex(PeripheralDeviceCommands, {
127123} )
128124
129125export const PeripheralDevices = createAsyncOnlyMongoCollection < PeripheralDevice > ( CollectionName . PeripheralDevices , {
130- update ( userId , doc , fields , _modifier ) {
131- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . PeripheralDevices , 'configure' ) ) return false
132-
126+ requiredPermissions : [ 'configure' ] ,
127+ update ( _permissions , doc , fields , _modifier ) {
133128 return allowOnlyFields ( doc , fields , [
134129 'name' ,
135130 'deviceName' ,
@@ -152,9 +147,8 @@ registerIndex(PeripheralDevices, {
152147} )
153148
154149export const RundownLayouts = createAsyncOnlyMongoCollection < RundownLayoutBase > ( CollectionName . RundownLayouts , {
155- async update ( userId , doc , fields ) {
156- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . RundownLayouts , 'configure' ) ) return false
157-
150+ requiredPermissions : [ 'configure' ] ,
151+ async update ( _permissions , doc , fields ) {
158152 return rejectFields ( doc , fields , [ '_id' , 'showStyleBaseId' ] )
159153 } ,
160154} )
@@ -169,9 +163,8 @@ registerIndex(RundownLayouts, {
169163} )
170164
171165export const ShowStyleBases = createAsyncOnlyMongoCollection < DBShowStyleBase > ( CollectionName . ShowStyleBases , {
172- async update ( userId , doc , fields ) {
173- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . ShowStyleBases , 'configure' ) ) return false
174-
166+ requiredPermissions : [ 'configure' ] ,
167+ async update ( _permissions , doc , fields ) {
175168 return rejectFields ( doc , fields , [ '_id' ] )
176169 } ,
177170} )
@@ -180,9 +173,8 @@ registerIndex(ShowStyleBases, {
180173} )
181174
182175export const ShowStyleVariants = createAsyncOnlyMongoCollection < DBShowStyleVariant > ( CollectionName . ShowStyleVariants , {
183- async update ( userId , doc , fields ) {
184- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . ShowStyleVariants , 'configure' ) ) return false
185-
176+ requiredPermissions : [ 'configure' ] ,
177+ async update ( _permissions , doc , fields ) {
186178 return rejectFields ( doc , fields , [ 'showStyleBaseId' ] )
187179 } ,
188180} )
@@ -192,9 +184,8 @@ registerIndex(ShowStyleVariants, {
192184} )
193185
194186export const Snapshots = createAsyncOnlyMongoCollection < SnapshotItem > ( CollectionName . Snapshots , {
195- update ( userId , doc , fields , _modifier ) {
196- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Snapshots , 'configure' ) ) return false
197-
187+ requiredPermissions : [ 'configure' ] ,
188+ update ( _permissions , doc , fields , _modifier ) {
198189 return allowOnlyFields ( doc , fields , [ 'comment' ] )
199190 } ,
200191} )
@@ -206,9 +197,8 @@ registerIndex(Snapshots, {
206197} )
207198
208199export const Studios = createAsyncOnlyMongoCollection < DBStudio > ( CollectionName . Studios , {
209- async update ( userId , doc , fields , _modifier ) {
210- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . Studios , 'configure' ) ) return false
211-
200+ requiredPermissions : [ 'configure' ] ,
201+ async update ( _permissions , doc , fields , _modifier ) {
212202 return rejectFields ( doc , fields , [ '_id' ] )
213203 } ,
214204} )
@@ -235,9 +225,8 @@ export const TranslationsBundles = createAsyncOnlyMongoCollection<TranslationsBu
235225)
236226
237227export const TriggeredActions = createAsyncOnlyMongoCollection < DBTriggeredActions > ( CollectionName . TriggeredActions , {
238- async update ( userId , doc , fields ) {
239- if ( ! checkUserIdHasOneOfPermissions ( userId , CollectionName . TriggeredActions , 'configure' ) ) return false
240-
228+ requiredPermissions : [ 'configure' ] ,
229+ async update ( _permissions , doc , fields ) {
241230 return rejectFields ( doc , fields , [ '_id' ] )
242231 } ,
243232} )
0 commit comments