diff --git a/static/index.html b/static/index.html index 415f6c9..16a7a32 100644 --- a/static/index.html +++ b/static/index.html @@ -98,7 +98,6 @@ - diff --git a/static/js/main.js b/static/js/main.js index 176a0c7..fad0819 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -38,17 +38,32 @@ $(window).on("load", function() { $("#login-form").submit(function (e) { e.preventDefault(); var data = JSON.stringify({ - username: $("#login").val(), + user: $("#login").val(), password: $("#password").val() }); - $.post(base_url + "login", data, function (data) { - console.log(data); + $.ajax({ + type: "POST", + url: base_url + "login", + data: data, + contentType: "application/json; charset=utf-8", + dataType: "json", + + success: function (data) { + if(data.success) { + localStorage.setItem("token", data.token); + localStorage.setItem("user", data.user); + show_page('#demande-page'); + } else { + + } + + } }); }); $("#prank-button").click(function () { - if(Cookies.get('token')) { + if(localStorage.getItem('token')) { show_page('#demande-page'); } else {