From 642f8010f3eb9b481075ca8e7b260d4c363758e5 Mon Sep 17 00:00:00 2001 From: Yasser Fadl Date: Tue, 5 Jul 2016 22:54:37 +0200 Subject: [PATCH] AuthenticationHandler not plugin, dependency plugins don't specifiy their types --- src/authentication/open-authentication-handler.js | 4 +++- src/deepstream.io.js | 8 +++----- src/permission/open-permission-handler.js | 5 ++++- src/utils/dependency-initialiser.js | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/authentication/open-authentication-handler.js b/src/authentication/open-authentication-handler.js index e7bd84aa5..aaff6516f 100644 --- a/src/authentication/open-authentication-handler.js +++ b/src/authentication/open-authentication-handler.js @@ -1,4 +1,5 @@ 'use strict'; +const EventEmitter = require( 'events' ).EventEmitter; /** * Used for users that don't provide a username @@ -14,12 +15,13 @@ const OPEN = 'open'; * * @class OpenAuthenticationHandler */ -module.exports = class OpenAuthenticationHandler{ +module.exports = class OpenAuthenticationHandler extends EventEmitter{ /** * @param {String} type exposes the type for logging purposes. This one is called * none to avoid confusion with openAuth */ constructor() { + super(); this.type = 'none'; this.isReady = true; } diff --git a/src/deepstream.io.js b/src/deepstream.io.js index b3df0648e..9f71cd3bf 100644 --- a/src/deepstream.io.js +++ b/src/deepstream.io.js @@ -50,7 +50,8 @@ var Deepstream = function( config ) { 'messageConnector', 'storage', 'cache', - 'permissionHandler' //TODO: This now requires the permissionHandler to have a ready flag / emit events + 'authenticationHandler', + 'permissionHandler' ]; }; @@ -152,12 +153,9 @@ Deepstream.prototype._start = function() { } if( global.deepstreamLibDir ) { - this._options.logger.log( C.LOG_LEVEL.INFO, C.EVENT.INFO, 'library directory set to: ' + global.deepstreamLibDir ); + this._options.logger.log( C.LOG_LEVEL.INFO, C.EVENT.INFO, 'library directory set to: ' + global.deepstreamLibDir ); } - var authTypeMsg = 'authentication type ' + ( this._options.authenticationHandler.type || 'custom' ); - this._options.logger.log( C.LOG_LEVEL.INFO, C.EVENT.INFO, authTypeMsg ); - if( this._options.dataTransforms && this._options.dataTransforms instanceof Array ) { this._options.dataTransforms = new DataTransforms( this._options.dataTransforms ); } diff --git a/src/permission/open-permission-handler.js b/src/permission/open-permission-handler.js index 3760ed194..a852af98f 100644 --- a/src/permission/open-permission-handler.js +++ b/src/permission/open-permission-handler.js @@ -1,16 +1,19 @@ 'use strict'; +const EventEmitter = require( 'events' ).EventEmitter; + /** * The open permission handler allows any action to occur without applying * any permissions. * * @class OpenPermissionHandler */ -module.exports = class OpenPermissionHandler{ +module.exports = class OpenPermissionHandler extends EventEmitter{ /** * @param {String} type exposes the type for logging purposes */ constructor() { + super(); this.type = 'none'; this.isReady = true; } diff --git a/src/utils/dependency-initialiser.js b/src/utils/dependency-initialiser.js index a11f4c98e..dcb6ea76f 100644 --- a/src/utils/dependency-initialiser.js +++ b/src/utils/dependency-initialiser.js @@ -56,7 +56,8 @@ DependencyInitialiser.prototype._onReady = function() { clearTimeout( this._timeout ); } - this._options.logger.log( C.LOG_LEVEL.INFO, C.EVENT.INFO, this._name + ' ready' ); + var dependencyType = this._dependency.type ? ': ' + this._dependency.type : '' + this._options.logger.log( C.LOG_LEVEL.INFO, C.EVENT.INFO, `${this._name} ready${dependencyType}` ); process.nextTick( this._emitReady.bind( this ) ); };