From 6df4fee7c805085b09d5913ef567c0e245d8c9ff Mon Sep 17 00:00:00 2001 From: Richard Walker Date: Thu, 6 Mar 2014 23:11:01 +0100 Subject: [PATCH] Add admittance module --- admittance.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 admittance.js diff --git a/admittance.js b/admittance.js new file mode 100644 index 0000000..34f3e4c --- /dev/null +++ b/admittance.js @@ -0,0 +1,23 @@ +'use strict'; + +var util = require('util') + +var permissions = {} + +var admittance = function (userid) { + return { + is: function (permission) { + + if (util.isArray(permissions[userid])) + if (permissions[userid].indexOf(permission) !== -1) return true + + return permissions[userid] === permission + } + } +} + +admittance.load = function (permissionData) { + permissions = permissionData +} + +module.exports = admittance