identity
Version:
Identity client
47 lines (32 loc) • 1.2 kB
JavaScript
var OpenRecord = require('openrecord');
exports.identity = function(api, next){
var config = api.config.identity;
if(!config) return next();
api.identity = {site: config.site};
//call action on any other application connected to the identity server
api.identity.application = require('../lib/app_communication')(api, config);
//set default values
config.session_prefix = config.session_prefix || '__session';
config.session_ttl = 60*60;
api.identity.store = new OpenRecord({
type: 'rest',
name: 'identity',
url: config.site,
path: 'api/application/',
models: __dirname + '/../openrecord/models/*',
plugins: __dirname + '/../openrecord/plugins/*',
global: config.global_models,
actionhero: api,
simplifyAdminRole: config.simplifyAdminRole
});
api.identity.store.on('exception', function(err){
api.exceptionHandlers.report(err, 'rest', 'identity', {}, 'error');
});
api.identity._start = function(api, next){
if(!api.db) return next();
//add identity to the global stores of ah-openrecord-plugin
api.db.constructor.registerStore(this.store)
next();
};
next();
};