UNPKG

dl

Version:

DreamLab Libs

35 lines (32 loc) 1.01 kB
/** * Description of Services * * @param {Object} data Services data * @constructor */ var NauthUserServices = function (data) { this._data = data || {}; }; /** * Information whether user has account in given application within given portal * * @param {Number} appId Application ID * @param {Number} portalId Portal ID * @type Boolean */ NauthUserServices.prototype.hasAccountInApplication = function (appId, portalId) { return this._data.hasOwnProperty(portalId) && this._data[portalId].hasOwnProperty(appId) && this._data[portalId][appId] !== null; }; /** * Returns user account ID in given application within given portal. * Otherwise returns Null * * @param {Number} addId Application ID * @param {Number} portalId Portal ID * @type Number|Null */ NauthUserServices.prototype.getIdInApplication = function (appId, portalId) { return this.hasAccountInApplication(appId, portalId) ? this._data[portalId][appId] : null; }; exports.NauthUserServices = NauthUserServices;