[add] Logout

Also made general fixes to the css
This commit is contained in:
Jose Pabl Domingo Aramburo Sanchez 2018-08-12 10:03:25 -06:00
parent de84da4482
commit d4fadf08bc
6 changed files with 48 additions and 33 deletions

View File

@ -1,23 +1,12 @@
body { body {
background-color: #e3e3e3; background-color: #e3e3e3;
/* Se agrego color blanco a letra en panel en general*/
color: #000; color: #000;
} }
/*Cambia el color del date picker a negro para permitir su visibilidad*/
.datepicker{ .datepicker{
color: black; 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{ #cuerpo{
top:17%; top:17%;
left:1%; left:1%;
@ -78,7 +67,6 @@ body {
} }
/* botoner<65>a panel principal */
.metro{ .metro{
width:auto; width:auto;
height:auto; height:auto;
@ -199,7 +187,7 @@ body {
} }
} }
/* FORMATO PARA TEXTO CUSTOM */
.formato_texto_custom{ .formato_texto_custom{
width: 97%; width: 97%;
float: left; float: left;

View File

@ -18,7 +18,7 @@ body {
padding: 20px; padding: 20px;
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
border-top: 5px solid #bdb035; border-top: 5px solid #5bc0de;
margin: 0 auto; margin: 0 auto;
} }
.login-block h1 { .login-block h1 {
@ -58,15 +58,15 @@ body {
background-size: 16px 80px; background-size: 16px 80px;
} }
.login-block input:active, .login-block input:focus { .login-block input:active, .login-block input:focus {
border: 1px solid #bdb035; border: 1px solid #5bc0de;
} }
.login-block #loginButon { .login-block #loginButon {
width: 100%; width: 100%;
height: 40px; height: 40px;
background: #bdb035; background: #009bad;
box-sizing: border-box; box-sizing: border-box;
border-radius: 5px; border-radius: 5px;
border: 1px solid #6d661c; border: 1px solid #000;
color: #fff; color: #fff;
font-weight: bold; font-weight: bold;
text-transform: uppercase; text-transform: uppercase;
@ -75,7 +75,7 @@ body {
outline: none; outline: none;
cursor: pointer; cursor: pointer;
} }
.login-block button:hover {
background: #c7b935; #modalLoginErrorHeader{
border: 1px solid #6d661c; background-color: #d9534f;
} }

View File

@ -47,7 +47,7 @@ if(!isset($_SESSION['userName'])){
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
<a href="../logout.php"><span class="fa fa-fw fa-power-off"></span> Cerrar Sesión</a> <a href="#" onclick="logout();"><span class="fa fa-fw fa-power-off"></span> Cerrar Sesión</a>
</li> </li>
</ul> </ul>
@ -239,4 +239,5 @@ if(!isset($_SESSION['userName'])){
</body> </body>
<script src="../js/getBaseUrl.js"></script> <script src="../js/getBaseUrl.js"></script>
<link href="../css/panel.css" rel="stylesheet"> <script src="../js/landing.js"></script>
<link href="../css/landing.css" rel="stylesheet">

View File

@ -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";
}
},
});
}

View File

@ -1,26 +1,38 @@
/**
* Maps the enter key to the login action
*/
$(document).keypress(function(e) { $(document).keypress(function(e) {
if(e.which == 13) { if(e.which == 13) {
processLogin(); 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() { function processLogin() {
var baseUrl = getbaseUrl(); var baseUrl = getbaseUrl();
var parametros = { var parameters = {
"userName":$('#userName').val(), "userName":$('#userName').val(),
"password":$('#password').val() "password":$('#password').val()
}; };
$.ajax({ $.ajax({
url: baseUrl + '/index.php/api/session/login', url: baseUrl + '/api/session/login',
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: parametros, data: parameters,
success:function(data){ success:function(data){
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
if(data["status"] == "success"){ if(data["status"] == "success"){
redirect(baseUrl + '/html/landing.php'); window.location.replace(baseUrl + '/html/landing.php');
}else if(data["status"] == "success" || (data["status"] === undefined)){ }else if(data["status"] == "success" || (data["status"] === undefined)){
$('#modalLoginError').modal('show'); $('#modalLoginError').modal('show');
document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page."; document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page.";
@ -34,7 +46,3 @@ function processLogin() {
}, },
}); });
} }
function redirect(url){
window.location.replace(url);
}

View File

@ -117,12 +117,12 @@ class SessionApplication{
} }
/** /**
* @return string * @return array
*/ */
function destroySession(){ function destroySession(){
session_destroy(); session_destroy();
return "Sucessfully logged out."; return array('status' => 'success', 'message' => 'Successfully logged out.');
} }
} }
?> ?>