Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- 'use strict';
- angular
- .module('nBlogsApplicationApp')
- .factory('authToken', authToken);
- function authToken($window) {
- var service = {
- setToken: setToken,
- getToken: getToken,
- isAuthenticated: isAuthenticated,
- removeToken: removeToken
- };
- return service;
- function setToken(token) {
- $window.localStorage.setItem('userToken', token);
- }
- function getToken() {
- return $window.localStorage.getItem('userToken');
- }
- function isAuthenticated() {
- return !!authToken.getToken();
- }
- function removeToken() {
- $window.localStorage.removeItem('userToken');
- }
- }
- })();
- (function () {
- angular
- .module('nBlogsApplicationApp')
- .run(appRun);
- function appRun(Restangular, authToken) {
- authToken.setToken('ZmVtYWxlOmZlbWFsZQ==');
- Restangular.setDefaultHeaders(
- {
- 'Authorization': 'Basic ' + authToken.getToken() + '',
- 'Prefer': 'status=422'
- }
- );
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement