[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 {
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<65>a panel principal */
.metro{
width:auto;
height:auto;
@ -199,7 +187,7 @@ body {
}
}
/* FORMATO PARA TEXTO CUSTOM */
.formato_texto_custom{
width: 97%;
float: left;

View File

@ -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;
}
#modalLoginErrorHeader{
background-color: #d9534f;
}

View File

@ -47,7 +47,7 @@ if(!isset($_SESSION['userName'])){
</ul>
<ul class="nav navbar-nav navbar-right">
<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>
</ul>
@ -239,4 +239,5 @@ if(!isset($_SESSION['userName'])){
</body>
<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) {
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);
}

View File

@ -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.');
}
}
?>