fixed social authd user license issue

This commit is contained in:
John Mitchell
2015-11-17 13:49:16 -05:00
parent e8d420abeb
commit a54e7101dd

View File

@@ -23,11 +23,11 @@ export default
'FormGenerator', 'ParseHelper', 'ModalDialog', 'VariablesHelper', 'LicenseFormDefinition']) 'FormGenerator', 'ParseHelper', 'ModalDialog', 'VariablesHelper', 'LicenseFormDefinition'])
.factory('CheckLicense', ['$rootScope', '$compile', 'CreateDialog', 'Store', .factory('CheckLicense', ['$q', '$rootScope', '$compile', 'CreateDialog', 'Store',
'LicenseUpdateForm', 'GenerateForm', 'TextareaResize', 'ToJSON', 'GetBasePath', 'LicenseUpdateForm', 'GenerateForm', 'TextareaResize', 'ToJSON', 'GetBasePath',
'Rest', 'ProcessErrors', 'Alert', 'IsAdmin', '$location', 'pendoService', 'Rest', 'ProcessErrors', 'Alert', 'IsAdmin', '$location', 'pendoService',
'Authorization', 'Wait', 'Authorization', 'Wait',
function($rootScope, $compile, CreateDialog, Store, LicenseUpdateForm, GenerateForm, function($q, $rootScope, $compile, CreateDialog, Store, LicenseUpdateForm, GenerateForm,
TextareaResize, ToJSON, GetBasePath, Rest, ProcessErrors, Alert, IsAdmin, $location, TextareaResize, ToJSON, GetBasePath, Rest, ProcessErrors, Alert, IsAdmin, $location,
pendoService, Authorization, Wait) { pendoService, Authorization, Wait) {
return { return {
@@ -201,27 +201,49 @@ export default
test: function() { test: function() {
var license = Store('license'), var license = Store('license'),
notify = this.shouldNotify(license),
self = this, self = this,
scope; scope;
self.scope = $rootScope.$new(); var getLicense = function() {
scope = self.scope; var deferred = $q.defer();
if (license && typeof license === 'object' && Object.keys(license).length > 0) { if (license === null) {
if (license.tested) { Rest.setUrl(GetBasePath('config'));
return true; return Rest.get()
.then(function (data) {
license = data.data.license_info;
deferred.resolve();
return deferred.promise;
}, function () {
deferred.resolve();
return deferred.promise;
});
} else {
deferred.resolve(license);
return deferred.promise;
} }
license.tested = true;
Store('license',license); //update with tested flag
} }
// Don't do anything when the license is valid var promise = getLicense();
if (!notify) { promise.then(function() {
return true; // if the license is valid it would exit 'test' here, otherwise it moves on to making the modal for the license self.scope = $rootScope.$new();
} scope = self.scope;
$location.path('/license'); if (license && typeof license === 'object' && Object.keys(license).length > 0) {
if (license.tested) {
return true;
}
license.tested = true;
Store('license',license); //update with tested flag
}
// Don't do anything when the license is valid
if (!self.shouldNotify(license)) {
return true; // if the license is valid it would exit 'test' here, otherwise it moves on to making the modal for the license
}
$location.path('/license');
});
}, },
GetLicense: function(callback, inScope) { GetLicense: function(callback, inScope) {