ionic-coreo
Version:
Ionic2 module for integration with Coreo
49 lines • 1.7 kB
JavaScript
;
var core_1 = require('@angular/core');
var storage_1 = require('@ionic/storage');
var CoreoTokenContext = (function () {
function CoreoTokenContext(storage) {
this.storage = storage;
this.key = 'coreo.token';
this.token = null;
this.load();
}
CoreoTokenContext.prototype.get = function () {
return this.token;
};
CoreoTokenContext.prototype.load = function () {
var _this = this;
return this.storage.ready().then(function () {
_this.storage.get(_this.key).then(function (result) {
if (result) {
var token = JSON.parse(result);
_this.token = token;
return token;
}
return result;
});
});
};
CoreoTokenContext.prototype.set = function (token) {
var _this = this;
this.token = token;
this.storage.ready().then(function () { return _this.storage.set('coreo.token', JSON.stringify(token)); });
};
CoreoTokenContext.prototype.clear = function () {
var _this = this;
this.token = null;
this.storage.ready().then(function () { return _this.storage.remove(_this.key); });
};
CoreoTokenContext.decorators = [
{ type: core_1.Injectable },
];
/** @nocollapse */
CoreoTokenContext.ctorParameters = function () { return [
{ type: storage_1.Storage, },
]; };
return CoreoTokenContext;
}());
exports.CoreoTokenContext = CoreoTokenContext;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = CoreoTokenContext;
//# sourceMappingURL=token-context.js.map