diff --git a/api-payroll/public/css/panel.css b/api-payroll/public/css/landing.css similarity index 92% rename from api-payroll/public/css/panel.css rename to api-payroll/public/css/landing.css index 365cfee..bad377c 100644 --- a/api-payroll/public/css/panel.css +++ b/api-payroll/public/css/landing.css @@ -1,23 +1,12 @@ body { background-color: #e3e3e3; - /* Se agrego color blanco a letra en panel en general*/ color: #000; } -/*Cambia el color del date picker a negro para permitir su visibilidad*/ .datepicker{ color: black; } -/*El color con el que se muestra el peso del archivo en la carga masiva se imagenes*/ -.size{ - color: black; -} - -.calendar{ - background: #fff; -} - #cuerpo{ top:17%; left:1%; @@ -78,7 +67,6 @@ body { } -/* botoner�a panel principal */ .metro{ width:auto; height:auto; @@ -199,7 +187,7 @@ body { } } -/* FORMATO PARA TEXTO CUSTOM */ + .formato_texto_custom{ width: 97%; float: left; diff --git a/api-payroll/public/css/login.css b/api-payroll/public/css/login.css index c8b4eae..7b2d9ee 100644 --- a/api-payroll/public/css/login.css +++ b/api-payroll/public/css/login.css @@ -18,7 +18,7 @@ body { padding: 20px; background: #fff; border-radius: 5px; - border-top: 5px solid #bdb035; + border-top: 5px solid #5bc0de; margin: 0 auto; } .login-block h1 { @@ -58,15 +58,15 @@ body { background-size: 16px 80px; } .login-block input:active, .login-block input:focus { - border: 1px solid #bdb035; + border: 1px solid #5bc0de; } .login-block #loginButon { width: 100%; height: 40px; - background: #bdb035; + background: #009bad; box-sizing: border-box; border-radius: 5px; - border: 1px solid #6d661c; + border: 1px solid #000; color: #fff; font-weight: bold; text-transform: uppercase; @@ -75,7 +75,7 @@ body { outline: none; cursor: pointer; } -.login-block button:hover { - background: #c7b935; - border: 1px solid #6d661c; -} \ No newline at end of file + +#modalLoginErrorHeader{ + background-color: #d9534f; +} diff --git a/api-payroll/public/html/landing.php b/api-payroll/public/html/landing.php index 76b342a..b0c3563 100644 --- a/api-payroll/public/html/landing.php +++ b/api-payroll/public/html/landing.php @@ -47,7 +47,7 @@ if(!isset($_SESSION['userName'])){ @@ -239,4 +239,5 @@ if(!isset($_SESSION['userName'])){ - \ No newline at end of file + + \ No newline at end of file diff --git a/api-payroll/public/js/landing.js b/api-payroll/public/js/landing.js new file mode 100644 index 0000000..809bd1e --- /dev/null +++ b/api-payroll/public/js/landing.js @@ -0,0 +1,18 @@ +function logout() { + var baseUrl = getbaseUrl(); + + $.ajax({ + url: baseUrl + '/api/session/logout', + type: 'GET', + dataType: 'json', + success:function(data){ + window.location.replace(baseUrl + '/html/login.php'); + }, + error:function(x) { + if (x.status==500){ + $('#modalLoginError').modal('show'); + document.getElementById('modalLoginErrorBody').innerHTML = "The user or password didnt match, please try again"; + } + }, + }); +} \ No newline at end of file diff --git a/api-payroll/public/js/login.js b/api-payroll/public/js/login.js index 494934d..384f3d0 100644 --- a/api-payroll/public/js/login.js +++ b/api-payroll/public/js/login.js @@ -1,26 +1,38 @@ +/** + * Maps the enter key to the login action + */ $(document).keypress(function(e) { if(e.which == 13) { processLogin(); } }); +/** + * Takes the input from the username and password fields and send theem to the backend + * to be validated + * + * The response from the api will contain a status that will determine if the login was + * successful or not and a message that will contain feedback which can be used to + * display errors to the user + */ function processLogin() { var baseUrl = getbaseUrl(); - var parametros = { + var parameters = { "userName":$('#userName').val(), "password":$('#password').val() }; $.ajax({ - url: baseUrl + '/index.php/api/session/login', + url: baseUrl + '/api/session/login', type: 'POST', dataType: 'json', - data: parametros, + data: parameters, success:function(data){ console.log(JSON.stringify(data)); if(data["status"] == "success"){ - redirect(baseUrl + '/html/landing.php'); + window.location.replace(baseUrl + '/html/landing.php'); + }else if(data["status"] == "success" || (data["status"] === undefined)){ $('#modalLoginError').modal('show'); document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page."; @@ -33,8 +45,4 @@ function processLogin() { } }, }); -} - -function redirect(url){ - window.location.replace(url); } \ No newline at end of file diff --git a/api-payroll/src/application/SessionApplication.php b/api-payroll/src/application/SessionApplication.php index 43855e2..a02b86e 100644 --- a/api-payroll/src/application/SessionApplication.php +++ b/api-payroll/src/application/SessionApplication.php @@ -117,12 +117,12 @@ class SessionApplication{ } /** - * @return string + * @return array */ function destroySession(){ session_destroy(); - return "Sucessfully logged out."; + return array('status' => 'success', 'message' => 'Successfully logged out.'); } } ?> \ No newline at end of file