Skip to content

Instantly share code, notes, and snippets.

@vmakhaev
Forked from cray0000/accessControl.coffee
Created December 6, 2013 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmakhaev/7829731 to your computer and use it in GitHub Desktop.
Save vmakhaev/7829731 to your computer and use it in GitHub Desktop.
ALLOWED_COLLECTIONS = [
'auths' # Private user data
]
store.allow 'create', 'auths', (docId, newDoc, session) ->
console.log '[Auths] CREATE'
undefined
store.allow 'all', 'auths.*', (docId, relPath, opData, docBeingUpdated, session) ->
console.log '[Auths] CHANGE'
return undefined if session.userId in store.ADMINS
if docBeingUpdated and docId isnt session.userId
'Unauthorized auth change'
else
undefined
store.allow 'del', 'auths', (docId, docToRemove, session) ->
console.log '[Auths] DELETE'
'Unauthorized auth delete'
store.allow 'all', '**', (docId, relPath, opData, docBeingUpdated, connectSession) ->
'Unauthorized action' unless opData.collection in ALLOWED_COLLECTIONS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment