Add Role.findByName and more comments
This commit is contained in:
parent
af2b8dd4ff
commit
a72a42e436
|
@ -96,15 +96,15 @@ var ACL = loopback.createModel('ACL', ACLSchema);
|
||||||
|
|
||||||
ACL.ALL = '*';
|
ACL.ALL = '*';
|
||||||
|
|
||||||
ACL.DEFAULT = 'DEFAULT';
|
ACL.DEFAULT = 'DEFAULT'; // Not specified
|
||||||
ACL.ALLOW = 'ALLOW';
|
ACL.ALLOW = 'ALLOW'; // Allow
|
||||||
ACL.ALARM = 'ALARM';
|
ACL.ALARM = 'ALARM'; // Warn - send an alarm
|
||||||
ACL.AUDIT = 'AUDIT';
|
ACL.AUDIT = 'AUDIT'; // Audit - record the access
|
||||||
ACL.DENY = 'DENY';
|
ACL.DENY = 'DENY'; // Deny
|
||||||
|
|
||||||
ACL.READ = 'READ';
|
ACL.READ = 'READ'; // Read operation
|
||||||
ACL.WRITE = 'WRITE';
|
ACL.WRITE = 'WRITE'; // Write operation
|
||||||
ACL.EXECUTE = 'EXECUTE';
|
ACL.EXECUTE = 'EXECUTE'; // Execute operation
|
||||||
|
|
||||||
ACL.USER = 'USER';
|
ACL.USER = 'USER';
|
||||||
ACL.APP = ACL.APPLICATION = 'APP';
|
ACL.APP = ACL.APPLICATION = 'APP';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var loopback = require('../loopback');
|
var loopback = require('../loopback');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
// Role model
|
// Role model
|
||||||
var RoleSchema = {
|
var RoleSchema = {
|
||||||
|
@ -91,6 +92,11 @@ var Role = loopback.createModel('Role', RoleSchema, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Role.findByName = function(name, callback) {
|
||||||
|
assert(name, 'Name is required');
|
||||||
|
Role.findOne({where: {name: name}}, callback);
|
||||||
|
};
|
||||||
|
|
||||||
// Set up the connection to users/applications/roles once the model
|
// Set up the connection to users/applications/roles once the model
|
||||||
Role.once('dataSourceAttached', function () {
|
Role.once('dataSourceAttached', function () {
|
||||||
Role.prototype.users = function (callback) {
|
Role.prototype.users = function (callback) {
|
||||||
|
|
Loading…
Reference in New Issue