UNPKG

angular2-devise-token-auth

Version:

Helper library for working with Devise Token Auth in your Angular 2 applications

35 lines 1.43 kB
"use strict"; var auth_config_1 = require('./auth.config'); var SessionController = (function () { function SessionController() { } SessionController.userSignedIn = function () { return this.getUserUid() !== null; }; SessionController.getUserUid = function () { return localStorage.getItem(this.config.uid); }; SessionController.setUser = function (headers) { this.config.authHeaders.forEach(function (header) { return localStorage.setItem(header, headers.get(header)); }); }; SessionController.removeUser = function () { this.config.authHeaders.forEach(function (header) { return localStorage.removeItem(header); }); }; SessionController.renewAccess = function (headers) { [ this.config.accessToken, this.config.client, ].forEach(function (header) { return localStorage.setItem(header, headers.get(header)); }); }; SessionController.getAuthHeaders = function () { var headers = []; this.config.authHeaders.forEach(function (header) { return headers[header] = localStorage.getItem(header); }); return headers; }; SessionController.config = new auth_config_1.AuthConfig({ globalHeaders: [{ 'Content-Type': 'application/json' }] }); return SessionController; }()); exports.SessionController = SessionController; //# sourceMappingURL=session.controller.js.map