Created
July 30, 2015 15:19
-
-
Save gblnovaes/c5b04bddbad52a9f403b to your computer and use it in GitHub Desktop.
Teste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var service = angular.module('inApp'); | |
service.factory('AuthService', function($http,$location,$window) { | |
return { | |
hasToken: function() { | |
// verifica se tem token senao tiver direciona para o login. | |
var token = $window.localStorage.getItem('access_token'); | |
var redirect = '/#'; | |
if(token == null || !token){ | |
$window.location.href = redirect; | |
} | |
}, | |
getToken: function() { | |
// consultar local store | |
// se nao existir tiro o cara | |
// se existir monto no padrao de devolucao | |
var token = $window.localStorage.getItem('access_token'); | |
var redirect = '/#'; | |
if(token == null || !token){ | |
$window.location.href = redirect; | |
}else{ | |
console.log($window.localStorage.getItem('access_token')); | |
var header = { | |
headers: { | |
'Authorization': 'Baerer ' + token | |
} | |
}; | |
return header; | |
} | |
} | |
}; | |
}); | |
service['$inject'] = ['$http', 'AuthService','$location','$window']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment