From 9f10b64f077f9b97dc64a3347f794456e48fecaa Mon Sep 17 00:00:00 2001 From: lusabo Date: Wed, 11 Jun 2014 12:24:35 -0300 Subject: [PATCH] Ajustes no controller js. --- archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js | 3 +++ archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js index 578aad2..75d4b55 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js @@ -63,6 +63,9 @@ function saveOk(data) { function saveFailed(request) { switch (request.status) { + case 401: + alert('Você não está autenticado.'); + break; case 412: $($("form input").get().reverse()).each(function() { var id = $(this).attr('id'); diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js index 8a44cce..7e40565 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/login.js @@ -15,14 +15,23 @@ $(function() { }); +// Função utilitária +function make_base_auth(user, password) { + var tok = user + ':' + password; + var hash = btoa(tok); + return "Basic " + hash; +} + // Funções de Callback function loginOk(data) { - location.href = "pendencies.html"; + sessionStorage.setItem('credential', + make_base_auth($("#username").val().trim(), $("#password").val().trim())); + location.href = "bookmark-list.html"; } function loginFail(request) { - + sessionStorage.clear(); switch (request.status) { case 401: $("#global-message").html("Usuário ou senha inválidos.").show(); -- libgit2 0.21.2