diff --git a/src/server/daemon/controller.js b/src/server/daemon/controller.js index 8092b89..0900b60 100644 --- a/src/server/daemon/controller.js +++ b/src/server/daemon/controller.js @@ -244,7 +244,7 @@ function _initExportService( db, callback ) ExportService .use( TokenedService( 'c1import', - new TokenDao( collection ), + new TokenDao( collection, "exports" ), function tokgen() { var shasum = crypto.createHash( 'sha1' ); diff --git a/src/server/token/TokenDao.ts b/src/server/token/TokenDao.ts index 49ec7cf..0fbe1a0 100644 --- a/src/server/token/TokenDao.ts +++ b/src/server/token/TokenDao.ts @@ -50,15 +50,21 @@ export = class TokenDao */ private readonly _collection: MongoCollection; + /** + * Field storing token data, relative to document root + */ + private readonly _rootField: string; + /** * Initialize connection * * @param collection Mongo collection */ - constructor( collection: MongoCollection ) + constructor( collection: MongoCollection, root_field: string ) { this._collection = collection; + this._rootField = root_field; } @@ -169,7 +175,7 @@ export = class TokenDao return; } - const field = data.exports || {}; + const field = data[ this._rootField ] || {}; if ( !field[ ns ] ) { @@ -252,7 +258,7 @@ export = class TokenDao private _genRoot( ns: string ): string { // XXX: injectable - return 'exports.' + ns; + return this._rootField + '.' + ns; } };