@akveo/nga-auth
Version:
@akveo/nga-auth
33 lines • 1.26 kB
JavaScript
import { Response, ResponseOptions } from '@angular/http';
import { deepExtend, getDeepFromObject } from '../helpers';
var NgaAbstractAuthProvider = (function () {
function NgaAbstractAuthProvider() {
this.defaultConfig = {};
this.config = {};
}
NgaAbstractAuthProvider.prototype.setConfig = function (config) {
this.config = deepExtend({}, this.defaultConfig, config);
};
NgaAbstractAuthProvider.prototype.getConfigValue = function (key) {
return getDeepFromObject(this.config, key, null);
};
NgaAbstractAuthProvider.prototype.createFailResponse = function (data) {
return new Response(new ResponseOptions({ body: '{}', status: 401 }));
};
NgaAbstractAuthProvider.prototype.createSuccessResponse = function (data) {
return new Response(new ResponseOptions({ body: '{}', status: 200 }));
};
NgaAbstractAuthProvider.prototype.getJsonSafe = function (res) {
var json;
try {
json = res.json();
}
catch (e) {
json = {};
}
return json;
};
return NgaAbstractAuthProvider;
}());
export { NgaAbstractAuthProvider };
//# sourceMappingURL=abstract-auth.provider.js.map