MCPcopy Index your code
hub / github.com/codecombat/codecombat / hasWriteAccess

Method hasWriteAccess

app/models/CocoModel.js:389–402  ·  view source on GitHub ↗
(actor)

Source from the content-addressed store, hash-verified

387 }
388
389 hasWriteAccess (actor) {
390 // actor is a User object
391 let left
392 if (actor == null) { actor = me }
393 if (actor.isAdmin()) { return true }
394 if (actor.isArtisan() && this.editableByArtisans) { return true }
395 for (const permission of Array.from(((left = this.get('permissions', true)) != null ? left : []))) {
396 if ((permission.target === 'public') || (actor.get('_id') === permission.target)) {
397 if (['owner', 'write'].includes(permission.access)) { return true }
398 }
399 }
400
401 return false
402 }
403
404 getOwner () {
405 const ownerPermission = _.find(this.get('permissions', true), { access: 'owner' })

Callers 7

applyDeltaMethod · 0.80
getRenderDataMethod · 0.80
constructorMethod · 0.80
tryToBuildMethod · 0.80
getRenderDataMethod · 0.80
afterRenderMethod · 0.80
shouldSaveEntityMethod · 0.80

Calls 3

getMethod · 0.95
isAdminMethod · 0.80
isArtisanMethod · 0.80

Tested by

no test coverage detected