Login front #13
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
81
api-payroll/public/css/login.css
Normal file
81
api-payroll/public/css/login.css
Normal file
@ -0,0 +1,81 @@
|
||||
body {
|
||||
background: url(../imagenes/grey_background.jpg);
|
||||
background-size: cover;
|
||||
font-family: Montserrat;
|
||||
}
|
||||
@media only screen and (min-device-width: 480px) {
|
||||
body {
|
||||
background: url('../imagenes/grey_background.jpg') no-repeat fixed center center;
|
||||
}
|
||||
}
|
||||
.logo {
|
||||
width: 213px;
|
||||
height: 60px;
|
||||
margin: 30px auto;
|
||||
}
|
||||
.login-block {
|
||||
width: 320px;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
border-top: 5px solid #bdb035;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.login-block h1 {
|
||||
text-align: center;
|
||||
color: #000;
|
||||
font-size: 18px;
|
||||
text-transform: uppercase;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.login-block input {
|
||||
width: 100%;
|
||||
height: 42px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ccc;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
font-family: Montserrat;
|
||||
padding: 0 20px 0 50px;
|
||||
outline: none;
|
||||
}
|
||||
.login-block input#user {
|
||||
background: #fff url('../imagenes/login_username.png') 20px top no-repeat;
|
||||
background-size: 16px 80px;
|
||||
}
|
||||
.login-block input#user:focus {
|
||||
background: #fff url('../imagenes/login_username.png') 20px bottom no-repeat;
|
||||
background-size: 16px 80px;
|
||||
}
|
||||
.login-block input#password {
|
||||
background: #fff url('../imagenes/login_password.png') 20px top no-repeat;
|
||||
background-size: 16px 80px;
|
||||
}
|
||||
.login-block input#password:focus {
|
||||
background: #fff url('../imagenes/login_password.png') 20px bottom no-repeat;
|
||||
background-size: 16px 80px;
|
||||
}
|
||||
.login-block input:active, .login-block input:focus {
|
||||
border: 1px solid #bdb035;
|
||||
}
|
||||
.login-block #loginButon {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
background: #bdb035;
|
||||
box-sizing: border-box;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #6d661c;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
font-family: Montserrat;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.login-block button:hover {
|
||||
background: #c7b935;
|
||||
border: 1px solid #6d661c;
|
||||
}
|
44
api-payroll/public/html/login.php
Normal file
44
api-payroll/public/html/login.php
Normal file
@ -0,0 +1,44 @@
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
|
||||
<!-- jQuery library -->
|
||||
<script src="../js/jquery.min.js"></script>
|
||||
|
||||
<!-- Latest compiled JavaScript -->
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
|
||||
<div class="container">
|
||||
<div class="logo"></div>
|
||||
<div class="login-block">
|
||||
<form action="" method="post" name="Login_Form" class="login">
|
||||
<h1>Login</h1>
|
||||
<input type="text" value="" placeholder="User" id="userName" name="user" required="" autofocus=""/>
|
||||
<input type="password" value="" placeholder="Password" id="password" name="password" required=""/>
|
||||
<a href="#" class="btn btn-lg btn-warning btn-default" id="loginButon" name="login" value="Login" onclick="processLogin();">Login</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modalLoginError" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" id="modalLoginErrorHeader">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p id="modalLoginErrorBody"></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../js/login.js"></script>
|
||||
<link href="../css/login.css" rel="stylesheet">
|
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
api-payroll/public/imagenes/login_password.png
Normal file
BIN
api-payroll/public/imagenes/login_password.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
api-payroll/public/imagenes/login_username.png
Normal file
BIN
api-payroll/public/imagenes/login_username.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
38
api-payroll/public/js/login.js
Normal file
38
api-payroll/public/js/login.js
Normal file
@ -0,0 +1,38 @@
|
||||
function getbaseUrl(uriPath){
|
||||
var url = window.location.href;
|
||||
return url.substring(0, url.indexOf(uriPath));
|
||||
}
|
||||
|
||||
function processLogin() {
|
||||
console.log(getbaseUrl('html/'));
|
||||
var parametros = {
|
||||
"userName":$('#userName').val(),
|
||||
"password":$('#password').val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: getbaseUrl('/html/') + '/index.php/api/session/login',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: parametros,
|
||||
success:function(data){
|
||||
console.log(JSON.stringify(data));
|
||||
if(data["status"] == "success"){
|
||||
redirect("http://stackoverflow.com");
|
||||
}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.";
|
||||
}
|
||||
},
|
||||
error:function(x) {
|
||||
if (x.status==500){
|
||||
$('#modalLoginError').modal('show');
|
||||
document.getElementById('modalLoginErrorBody').innerHTML = "The user or password didnt match, please try again";
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function redirect(url){
|
||||
window.location.replace(url);
|
||||
}
|
@ -69,7 +69,7 @@ class SessionApplication{
|
||||
|
||||
// If the credentials don't match anything in the the records
|
||||
if(!isset($storedPassword)){
|
||||
throw new Exception('The user or password didnt match, please try again.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Already has a session
|
||||
@ -82,7 +82,22 @@ class SessionApplication{
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
throw new Exception('The user or password didnt match, please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userName
|
||||
* @param $password
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
function login($userName, $password){
|
||||
if($this->newSession($userName, $password)){
|
||||
return array('status' => 'success', 'message' => 'Logged in successfully.');
|
||||
}
|
||||
else{
|
||||
throw new Exception('The user or password didnt match, please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,14 +22,14 @@ $app->get('/api/session', function (Request $request, Response $response, array
|
||||
$app->post('/api/session/login', function ($request, $response) {
|
||||
$requestData = $request->getParsedBody();
|
||||
|
||||
$data = $this->sessionApplication->newSession($requestData['userName'], $requestData['password']);
|
||||
$data = $this->sessionApplication->login($requestData['userName'], $requestData['password']);
|
||||
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->write(json_encode($data));
|
||||
});
|
||||
|
||||
$app->post('/api/session/logout', function (Request $request, Response $response, array $args) {
|
||||
$app->get('/api/session/logout', function (Request $request, Response $response, array $args) {
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->write(json_encode($this->sessionApplication->destroySession()));
|
||||
|
Loading…
Reference in New Issue
Block a user