Skip to content

Commit ad133ea

Browse files
committed
Use _.hasIn for checking storage service method existence
_.has only looks at own properties on the class and does not look for inherited properties. In ES6 the methods defined for an instance of a class are not own properties and the _.has check results in false positives.
1 parent 273fd0a commit ad133ea

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ng-authentication-service.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@
8888
return undefined;
8989
}
9090
storeService = $injector.get(configuration.storageService);
91-
_.each(['get', 'has', 'remove', 'set'], function (methodName) {
92-
if (!_.has(storeService, methodName)) {
93-
$log.error('storageService is missing method: ', methodName);
94-
return undefined;
91+
_.each(['get', 'has', 'remove', 'set'], function (fnName) {
92+
if (!_.hasIn(storeService, fnName) || !_.isFunction(storeService[fnName])) {
93+
$log.error('storageService is missing function: ', fnName);
9594
}
9695
});
9796
}

0 commit comments

Comments
 (0)