Commit 9f10b64f077f9b97dc64a3347f794456e48fecaa

Authored by Luciano Borges
1 parent ca9835b4
Exists in master

Ajustes no controller js.

archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
... ... @@ -63,6 +63,9 @@ function saveOk(data) {
63 63  
64 64 function saveFailed(request) {
65 65 switch (request.status) {
  66 + case 401:
  67 + alert('Você não está autenticado.');
  68 + break;
66 69 case 412:
67 70 $($("form input").get().reverse()).each(function() {
68 71 var id = $(this).attr('id');
... ...
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js
... ... @@ -15,14 +15,23 @@ $(function() {
15 15  
16 16 });
17 17  
  18 +// Função utilitária
  19 +function make_base_auth(user, password) {
  20 + var tok = user + ':' + password;
  21 + var hash = btoa(tok);
  22 + return "Basic " + hash;
  23 +}
  24 +
18 25 // Funções de Callback
19 26  
20 27 function loginOk(data) {
21   - location.href = "pendencies.html";
  28 + sessionStorage.setItem('credential',
  29 + make_base_auth($("#username").val().trim(), $("#password").val().trim()));
  30 + location.href = "bookmark-list.html";
22 31 }
23 32  
24 33 function loginFail(request) {
25   -
  34 + sessionStorage.clear();
26 35 switch (request.status) {
27 36 case 401:
28 37 $("#global-message").html("Usuário ou senha inválidos.").show();
... ...