1/** 2 * Service 3 * @memberOf Service 4 * @namespace CidadaoService 5 * @desc Este service contém as definicoes globais utilizadas na 6 * parte do Cidadao para Autenticacao e Autorizacao 7 */ 8(function() { 9 "use strict"; 10 11 angular.module("cidadao.module").factory("cidadao.service", CidadaoService); 12 13 CidadaoService.$inject = [ 14 "$http", 15 "$localStorage", 16 "SERVER_PATH" 17 ]; 18 19 function CidadaoService($http, $localStorage, SERVER_PATH) { 20 var service = { 21 login: login, 22 logout: logout 23 }; 24 25 return service; 26 27 function login(email, password) { 28 // Credenciais enviadas EXCLUSIVAMENTE no corpo JSON da requisição POST. 29 // Isso evita que apareçam na query string da URL e, portanto, 30 // nos logs de acesso HTTP do JBoss/Undertow. 31 var payload = { 32 email: email || "", 33 senha: password || "" 34 }; 35 36 return $http 37 .post(SERVER_PATH + "/siscidadao/rest/v1/publico/cidadao/login", payload) 38 .then( 39 function(response) { 40 // SALVA LOCALSTORAGE COM EMAIL/TIMESTAMP DO USUARIO 41 $localStorage.session = JSON.stringify({ 42 timestamp: new Date() 43 }); 44 $localStorage.user = JSON.stringify({ 45 email: email 46 }); 47 return { success: true }; 48 }, 49 function(httpError) {
50 if (httpError.status == '400') { 51 throw httpError; 52 } 53 throw httpError; 54 } 55 ); 56 } 57 58 function logout() { 59 return $http 60 .post(SERVER_PATH + "/siscidadao/sec/cidadao/logout") 61 .then( 62 function(response) { 63 // APAGA LOCALSTORAGE COM INFO DO USUARIO 64 $localStorage.$reset(); 65 return { success: true }; 66 }, 67 function(httpError) { 68 throw httpError; 69 } 70 ); 71 } 72 } 73})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.