Skip to content

Instantly share code, notes, and snippets.

@gwuah
Last active January 16, 2019 11:46
Show Gist options
  • Save gwuah/eca9b3d52a40a3c5a3c96abfc4aa4f30 to your computer and use it in GitHub Desktop.
Save gwuah/eca9b3d52a40a3c5a3c96abfc4aa4f30 to your computer and use it in GitHub Desktop.
const Ottis = require('../lib');
const router = Ottis.router;
const {admin, customer} = require('./permissions');
/* Initialise Ottis with various roles */
const auth = Ottis(["admin","customer"]);
/* Admin Config */
auth.addConfigFor('admin').forResource('customers')({
config: admin.customers
}).forResource('anonymous-customers')({
config: admin.anonymousCustomers
}).forResource('products')({
config: admin.products
})
/* Customer Config */
auth.addConfigFor('customer').forResource('customers')({
config: customer.customers
}).forResource('anonymous-customers')({
config: customer.anonymousCustomers
}).forResource('products')({
config: customer.products
});
/* Take note of the exported method */
module.exports = auth.User;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment