Compare commits
No commits in common. "master" and "editingWorkedDays" have entirely different histories.
master
...
editingWor
71
README.rst
71
README.rst
@ -1,71 +0,0 @@
|
||||
=================
|
||||
Payroll manager
|
||||
=================
|
||||
|
||||
|codebuild|
|
||||
|
||||
This is a simple system to keep a record of employees where they will perform different tasks within the company and will be paid accordingly in a monthly bases.
|
||||
|
||||
.. contents::
|
||||
|
||||
Getting started
|
||||
-----------------
|
||||
|
||||
The system requires the following:
|
||||
- Ubuntu 16.04
|
||||
- php 7.0
|
||||
- composer
|
||||
- docker
|
||||
- docker-compose
|
||||
- mysql 5.7
|
||||
|
||||
Installation
|
||||
-----------------
|
||||
|
||||
Alternatively to installing all the packages and configuring the server it's possible to start up an instance of the system with docker-compose
|
||||
|
||||
To install docker
|
||||
.. code-block:: bash
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
|
||||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
apt-cache policy docker-ce
|
||||
|
||||
sudo apt-get install -y docker-ce
|
||||
|
||||
To install docker compose
|
||||
.. code-block:: bash
|
||||
sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
And finally the containers can be initialized by running
|
||||
.. code-block:: bash
|
||||
sudo docker-compose up --build -d
|
||||
|
||||
Sign in
|
||||
-----------------
|
||||
|
||||
The login page can be accessed at **http://localhost:8085/public/html/login.php**
|
||||
|
||||
To access the platform the user is **sloth** and the pasword **slothness**
|
||||
|
||||
Further reading
|
||||
-----------------
|
||||
To further read about the api and it's front-end
|
||||
`api-payroll <https://github.com/PootisPenserHere/payroll_manager/blob/master/api-payroll/README.rst>`_
|
||||
|
||||
More about the database `database <https://github.com/PootisPenserHere/payroll_manager/blob/master/database/README.rst>`_
|
||||
|
||||
|
||||
Data volumes
|
||||
-----------------
|
||||
Since the application is designed to run within containers a number of volumes has been created to persist the data, they can be found in the volumes directory on the root of the project
|
||||
|
||||
.. |codebuild| image:: https://s3.amazonaws.com/codefactory-us-east-1-prod-default-build-badges/passing.svg
|
||||
:target: https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiWm42eW80VzA2OXRTc2xIMXErZ1hlS1RpNnFCaDVMWENqSSsyU2x3dUpReEpCRUtaZGRmbklYaFN0anVEWW9NaGYvQ21PNk9tR25rZGtZMjNvR1ArbGdVPSIsIml2UGFyYW1ldGVyU3BlYyI6IjVXYjl3TWZnUVQ1MFZDQ0kiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master
|
||||
:alt: Build status of the master branch on amazon codebuild
|
27
api-payroll/README.md
Normal file
27
api-payroll/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Slim Framework 3 Skeleton Application
|
||||
|
||||
Use this skeleton application to quickly setup and start working on a new Slim Framework 3 application. This application uses the latest Slim 3 with the PHP-View template renderer. It also uses the Monolog logger.
|
||||
|
||||
This skeleton application was built for Composer. This makes setting up a new Slim Framework application quick and easy.
|
||||
|
||||
## Install the Application
|
||||
|
||||
Run this command from the directory in which you want to install your new Slim Framework application.
|
||||
|
||||
php composer.phar create-project slim/slim-skeleton [my-app-name]
|
||||
|
||||
Replace `[my-app-name]` with the desired directory name for your new application. You'll want to:
|
||||
|
||||
* Point your virtual host document root to your new application's `public/` directory.
|
||||
* Ensure `logs/` is web writeable.
|
||||
|
||||
To run the application in development, you can run these commands
|
||||
|
||||
cd [my-app-name]
|
||||
php composer.phar start
|
||||
|
||||
Run this command in the application directory to run the test suite
|
||||
|
||||
php composer.phar test
|
||||
|
||||
That's it! Now go build something cool.
|
@ -1,34 +0,0 @@
|
||||
=======
|
||||
The api
|
||||
=======
|
||||
|
||||
.. contents::
|
||||
|
||||
About
|
||||
-------
|
||||
The project has been built with slim in the backed and jquery with bootstrap for the front, both of them share the public folder from which they can be accessed by the general public.
|
||||
|
||||
Auth
|
||||
------
|
||||
The system uses cookie based sessions which are handled by a midleware, have a time to live of 10 minutes and are refreshed each time a new request is made to the api, further more the contents of the session itself has been secured with openssl.
|
||||
|
||||
Database
|
||||
---------
|
||||
To connect to the database pdo is used, its configuration can be found at **src/settings.php** under the mysql section. The following settings are set as default:
|
||||
- **PDO::ATTR_EMULATE_PREPARES** Has been set to true in order to lower the strain on the database by processing the prepare statements on the server side, if cache performance is desired this option should be changed to false
|
||||
- **PDO::ATTR_ERRMODE** Uses **PDO::ERRMODE_EXCEPTION** which will return all mysql errors as exceptions to prevent further execution of the software
|
||||
- **PDO::ATTR_DEFAULT_FETCH_MODE** uses **PDO::FETCH_ASSOC** and as such the query ouput system wide is expected as an associative array
|
||||
|
||||
Data protection
|
||||
----------------
|
||||
| Encryption has been applied to sensitive data, passwords are protected with with bcrypt and it's configuration can be found in the settings.php file, by default a cost of 12 is used for the hashing as well as a 16 characters randomly generated string (128 bits) as an iv.
|
||||
|
||||
| For data that needs to be both read and written such as names AES in mode cbc with 256 block size has been used.
|
||||
|
||||
| The reason to have choosen AES is the desire to make the process of securing the data both secure and affordable since many hardware manufacturers already have architectures designed to improce the speed of AES.
|
||||
|
||||
| **Important note**: While in this project the encryption password has been saved into the settings.php file it's adviced that in a real use case it's stored more securely or else where entirely such as a key management service.
|
||||
|
||||
Error handling
|
||||
---------------
|
||||
Should an exception be encountered it'll be caught by a middleware that will form a new response body, returning it with a 500 http code and a json object containing the keys status set to error as well as a message key that will contain the exception that was raised.
|
@ -17,8 +17,7 @@
|
||||
"slim/php-view": "^2.0",
|
||||
"monolog/monolog": "^1.17",
|
||||
"respect/validation": "^1.1",
|
||||
"tuupola/cors-middleware": "^0.5.2",
|
||||
"adbario/slim-secure-session-middleware": "^1.3"
|
||||
"tuupola/cors-middleware": "^0.5.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=4.8 < 6.0"
|
||||
|
140
api-payroll/composer.lock
generated
140
api-payroll/composer.lock
generated
@ -4,96 +4,9 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "19bc193d641803843178e87bf0465afe",
|
||||
"content-hash": "9eb8d110ad374a60767f92d76018504a",
|
||||
"hash": "93a9656f4e6eb0e25be1bad59ac6f487",
|
||||
"content-hash": "a3fc18885cc45d2733b77fa2081bdc72",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adbario/php-dot-notation",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/adbario/php-dot-notation.git",
|
||||
"reference": "5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f",
|
||||
"reference": "5e4b1fe29a8ae1140e370d520ed8b85dd5130a1f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Adbar\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Riku Särkinen",
|
||||
"email": "riku@adbar.io"
|
||||
}
|
||||
],
|
||||
"description": "PHP dot notation array access",
|
||||
"homepage": "https://github.com/adbario/php-dot-notation",
|
||||
"keywords": [
|
||||
"ArrayAccess",
|
||||
"dotnotation",
|
||||
"php"
|
||||
],
|
||||
"time": "2017-03-26 17:44:47"
|
||||
},
|
||||
{
|
||||
"name": "adbario/slim-secure-session-middleware",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/adbario/slim-secure-session-middleware.git",
|
||||
"reference": "f107191506b2c362f06f201f998891f315d6aaec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/adbario/slim-secure-session-middleware/zipball/f107191506b2c362f06f201f998891f315d6aaec",
|
||||
"reference": "f107191506b2c362f06f201f998891f315d6aaec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"adbario/php-dot-notation": "~1.2.0",
|
||||
"paragonie/random_compat": "^2.0",
|
||||
"php": ">=5.5",
|
||||
"slim/slim": "~3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Adbar\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Riku Särkinen",
|
||||
"email": "riku@adbar.io"
|
||||
}
|
||||
],
|
||||
"description": "Secure session middleware for Slim 3 framework",
|
||||
"homepage": "https://github.com/adbario/slim-secure-session-middleware",
|
||||
"keywords": [
|
||||
"middleware",
|
||||
"session",
|
||||
"slim"
|
||||
],
|
||||
"time": "2017-08-04 13:51:00"
|
||||
},
|
||||
{
|
||||
"name": "container-interop/container-interop",
|
||||
"version": "1.2.0",
|
||||
@ -304,55 +217,6 @@
|
||||
],
|
||||
"time": "2018-02-13 20:26:39"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v2.0.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/random_compat.git",
|
||||
"reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d",
|
||||
"reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*|5.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/random.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||
"keywords": [
|
||||
"csprng",
|
||||
"polyfill",
|
||||
"pseudorandom",
|
||||
"random"
|
||||
],
|
||||
"time": "2018-07-04 16:31:37"
|
||||
},
|
||||
{
|
||||
"name": "pimple/pimple",
|
||||
"version": "v3.2.3",
|
||||
|
@ -103,8 +103,6 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="updateEmployee();">Update</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
<a href="#" class="btn btn-lg btn-danger " onclick="deleteEmployee();">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,3 +1,12 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if(!isset($_SESSION['userName'])){
|
||||
header("Location: ./login.php");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
|
||||
@ -31,6 +40,10 @@
|
||||
<li>
|
||||
<a href="#" data-nav_accion="registerWorkDays.php" ><span class="glyphicon glyphicon-tasks"></span> Management</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" onclick="loadView();"><span class="glyphicon glyphicon-wrench"></span> Change password</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
|
@ -1,3 +1,12 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if(isset($_SESSION['userName'])){
|
||||
header("Location: ./landing.php");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
|
||||
|
@ -85,7 +85,6 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="saveNewEmployee();">Create</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -134,7 +134,6 @@
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="processSaveActionWorkDay();">Save</a>
|
||||
<a href="#" class="btn btn-lg btn-primary " onclick="loadView(currentView);">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,6 +11,8 @@ if (PHP_SAPI == 'cli-server') {
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
session_start();
|
||||
|
||||
// Instantiate the app
|
||||
$settings = require __DIR__ . '/../src/settings.php';
|
||||
$app = new \Slim\App($settings);
|
||||
|
@ -134,43 +134,6 @@ function loadEmployeeData(code){
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Will change the status of an employee to remove them from the
|
||||
* active employee list
|
||||
*/
|
||||
function deleteEmployee(){
|
||||
let baseUrl = getbaseUrl();
|
||||
let code = $('#editEmployeeCode').val();
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/api/employee/' + code,
|
||||
type: 'DELETE',
|
||||
dataType: 'json',
|
||||
success:function(data){
|
||||
$('#modalServerResponseSuccess').modal('show');
|
||||
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['firstName'] + ' ' + data['middleName'] + ' ' + data['lastName'] + ' has been deleted.';
|
||||
},
|
||||
error:function(x,e) {
|
||||
let responseText = $.parseJSON(x["responseText"]);
|
||||
|
||||
if (x.status==0) {
|
||||
$('#modalErrorInternetConnection').modal('show');
|
||||
} else if(x.status==404) {
|
||||
$('#modalError404').modal('show');
|
||||
} else if(x.status==500) {
|
||||
$('#modalServerResponseError').modal('show');
|
||||
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||
} else if(e=='parsererror') {
|
||||
$('#modalErrorParsererror').modal('show');
|
||||
} else if(e=='timeout'){
|
||||
$('#modalErrorTimeout').modal('show');
|
||||
} else {
|
||||
$('#modalErrorOther').modal('show');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function updateEmployee(){
|
||||
let baseUrl = getbaseUrl();
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
// will contain the current loaded view
|
||||
let currentView;
|
||||
|
||||
/**
|
||||
* Destorys the session for the current user and redirects
|
||||
* back to the login form
|
||||
@ -16,15 +13,12 @@ function logout() {
|
||||
window.location.replace(baseUrl + '/html/login.php');
|
||||
},
|
||||
error:function(x,e) {
|
||||
let responseText = $.parseJSON(x["responseText"]);
|
||||
|
||||
if (x.status==0) {
|
||||
$('#modalErrorInternetConnection').modal('show');
|
||||
} else if(x.status==404) {
|
||||
$('#modalError404').modal('show');
|
||||
} else if(x.status==500) {
|
||||
$('#modalServerResponseError').modal('show');
|
||||
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||
$('#modalError500').modal('show');
|
||||
} else if(e=='parsererror') {
|
||||
$('#modalErrorParsererror').modal('show');
|
||||
} else if(e=='timeout'){
|
||||
@ -62,20 +56,15 @@ function loadView(requestedView){
|
||||
url: baseUrl + '/html/' + requestedView,
|
||||
type: 'get',
|
||||
success:function(data){
|
||||
currentView = requestedView;
|
||||
|
||||
$("#newViewBody").hide().html(data).show('slow');
|
||||
},
|
||||
error:function(x,e) {
|
||||
let responseText = $.parseJSON(x["responseText"]);
|
||||
|
||||
if (x.status==0) {
|
||||
$('#modalErrorInternetConnection').modal('show');
|
||||
} else if(x.status==404) {
|
||||
$('#modalError404').modal('show');
|
||||
} else if(x.status==500) {
|
||||
$('#modalServerResponseError').modal('show');
|
||||
document.getElementById('modalResponseError').innerHTML = responseText['message'];
|
||||
$('#modalError500').modal('show');
|
||||
} else if(e=='parsererror') {
|
||||
$('#modalErrorParsererror').modal('show');
|
||||
} else if(e=='timeout'){
|
||||
@ -86,11 +75,3 @@ function loadView(requestedView){
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the last view that was accessed as a way of fully clearing and
|
||||
* resetting the values of the form
|
||||
*/
|
||||
function clearView(view){
|
||||
loadView(view);
|
||||
}
|
||||
|
@ -9,28 +9,13 @@ class EmployeeApplication{
|
||||
private $cryptographyService;
|
||||
private $asserts;
|
||||
private $settings;
|
||||
private $session;
|
||||
|
||||
/**
|
||||
* EmployeeApplication constructor.
|
||||
* @param $employeeSettings
|
||||
* @param $mysql
|
||||
* @param $cryptographyService
|
||||
* @param $asserts
|
||||
* @param $session
|
||||
* @throws Exception
|
||||
*/
|
||||
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts, $session){
|
||||
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
|
||||
$this->settings = $employeeSettings;
|
||||
|
||||
$this->cryptographyService = $cryptographyService;
|
||||
$this->pdo = $mysql;
|
||||
$this->asserts = $asserts;
|
||||
$this->session = $session;
|
||||
|
||||
if(!$this->session->verifySession()){
|
||||
throw new Exception('A session is requited to access this resouerce.');
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,6 +81,7 @@ class EmployeeApplication{
|
||||
} catch( PDOExecption $e ) {
|
||||
$this->pdo->rollback();
|
||||
throw new Exception('There was an error while trying to save a new person.');
|
||||
$this->logger->warning("There was an error in the EmployeeApplication->saveNewPerson caused by: $e ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,19 +504,9 @@ class EmployeeApplication{
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code string
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
function disableEmployeeRecord($code){
|
||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||
|
||||
$idEmployee = $this->getIdEmployeeByCode($code);
|
||||
function disableEmployeeRecord($idEmployee){
|
||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||
|
||||
$employeeData = $this->proxyGetEmployeeDataById($idEmployee);
|
||||
|
||||
try {
|
||||
$stmt = $this->pdo->prepare("UPDATE employees
|
||||
SET
|
||||
@ -542,12 +518,8 @@ class EmployeeApplication{
|
||||
$this->pdo->commit();
|
||||
|
||||
$stmt = null;
|
||||
|
||||
return $employeeData;
|
||||
|
||||
} catch( PDOExecption $e ) {
|
||||
$this->pdo->rollback();
|
||||
throw new Exception("The employee you tried to delete could not be found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,11 @@ namespace App\Application;
|
||||
use Exception;
|
||||
|
||||
class SessionApplication{
|
||||
private $session;
|
||||
private $pdo;
|
||||
private $cryptographyService;
|
||||
private $asserts;
|
||||
|
||||
function __construct($session, $mysql, $cryptographyService, $asserts){
|
||||
$this->session = $session;
|
||||
function __construct($mysql, $cryptographyService, $asserts){
|
||||
$this->cryptographyService = $cryptographyService;
|
||||
$this->pdo = $mysql;
|
||||
$this->asserts = $asserts;
|
||||
@ -20,8 +18,7 @@ class SessionApplication{
|
||||
* @return bool
|
||||
*/
|
||||
function verifySession(){
|
||||
$userName = $this->session->get('userName');
|
||||
return isset($userName);
|
||||
return isset($_SESSION['userName']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,7 +30,7 @@ class SessionApplication{
|
||||
$session['loggedIn'] = $this->verifySession();
|
||||
|
||||
if($this->verifySession()){
|
||||
$session['userName'] = $this->session->get('userName');
|
||||
$session['userName'] = $_SESSION['userName'];
|
||||
}
|
||||
|
||||
return $session;
|
||||
@ -86,12 +83,7 @@ class SessionApplication{
|
||||
}
|
||||
|
||||
if($this->cryptographyService->decryptPassword($password, $storedPassword)){
|
||||
$this->session->set('userName', $userName);
|
||||
|
||||
if(!$this->verifySession()){
|
||||
throw new Exception('An error occurred while trying to create the session.');
|
||||
}
|
||||
|
||||
$_SESSION['userName'] = $userName;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
@ -124,14 +116,9 @@ class SessionApplication{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
function destroySession(){
|
||||
$this->session->clear();
|
||||
|
||||
if($this->verifySession()){
|
||||
throw new Exception('An error occurred while trying to end the session.');
|
||||
}
|
||||
session_destroy();
|
||||
|
||||
return array('status' => 'success', 'message' => 'Successfully logged out.');
|
||||
}
|
||||
|
@ -18,13 +18,6 @@ $container['logger'] = function ($c) {
|
||||
return $logger;
|
||||
};
|
||||
|
||||
// Session handler
|
||||
$container['session'] = function ($container) {
|
||||
return new \Adbar\Session(
|
||||
$container->get('settings')['session']['namespace']
|
||||
);
|
||||
};
|
||||
|
||||
// Mysql connection
|
||||
$container['mysql'] = function ($c) {
|
||||
$mysqlSettings = $c->get('settings')['mysql'];
|
||||
@ -67,8 +60,7 @@ $container['asserts'] = function ($c) {
|
||||
|
||||
// The session application
|
||||
$container['sessionApplication'] = function ($c) {
|
||||
$sessionApplication = new App\Application\SessionApplication($c['session'], $c['mysql'],
|
||||
$c['cryptographyService'], $c['asserts']);
|
||||
$sessionApplication = new App\Application\SessionApplication($c['mysql'], $c['cryptographyService'], $c['asserts']);
|
||||
return $sessionApplication;
|
||||
};
|
||||
|
||||
@ -76,6 +68,6 @@ $container['sessionApplication'] = function ($c) {
|
||||
$container['employeeApplication'] = function ($c) {
|
||||
$employeeSettings = $c->get('settings')['employee'];
|
||||
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
||||
$c['mysql'], $c['cryptographyService'], $c['asserts'], $c['sessionApplication']);
|
||||
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
||||
return $employeeApplication;
|
||||
};
|
||||
|
@ -20,5 +20,3 @@ $app->add(new \Tuupola\Middleware\Cors([
|
||||
->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
}
|
||||
]));
|
||||
|
||||
$app->add(new \Adbar\SessionMiddleware($app->getContainer()->get('settings')['session']));
|
@ -65,12 +65,12 @@ $app->put('/api/employee', function ($request, $response) {
|
||||
->write(json_encode($this->employeeApplication->updateEmployeeData($requestData)));
|
||||
});
|
||||
|
||||
$app->DELETE('/api/employee/{code}', function (Request $request, Response $response, array $args) {
|
||||
$code = $args['code'];
|
||||
$app->DELETE('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) {
|
||||
$idEmployee = $args['idEmployee'];
|
||||
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->write(json_encode($this->employeeApplication->disableEmployeeRecord($code)));
|
||||
->write(json_encode($this->employeeApplication->disableEmployeeRecord($idEmployee)));
|
||||
});
|
||||
|
||||
$app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) {
|
||||
|
@ -16,35 +16,6 @@ return [
|
||||
'level' => \Monolog\Logger::DEBUG,
|
||||
],
|
||||
|
||||
// Session handle settings
|
||||
'session' => [
|
||||
// Session cookie settings
|
||||
'name' => 'payroll-laziness-rocks',
|
||||
'lifetime' => 10,
|
||||
'path' => '/',
|
||||
'domain' => null,
|
||||
'secure' => false,
|
||||
'httponly' => true,
|
||||
|
||||
// Set session cookie path, domain and secure automatically
|
||||
'cookie_autoset' => true,
|
||||
|
||||
// Path where session files are stored, PHP's default path will be used if set null
|
||||
'save_path' => null,
|
||||
|
||||
// Session cache limiter
|
||||
'cache_limiter' => 'nocache',
|
||||
|
||||
// Extend session lifetime after each user activity
|
||||
'autorefresh' => true,
|
||||
|
||||
// Encrypt session data if string is set
|
||||
'encryption_key' => '7de431684c34cf2c898268cff71392f38c4175dde050c9ee69502b81571484e0',
|
||||
|
||||
// Session namespace
|
||||
'namespace' => 'slim'
|
||||
],
|
||||
|
||||
// Cryptography settings
|
||||
'cryptography' => [
|
||||
'encryptionAlgorithm' => 'AES-256-CBC',
|
||||
|
@ -20,7 +20,7 @@ class BaseTestCase extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $withMiddleware = false;
|
||||
protected $withMiddleware = true;
|
||||
|
||||
/**
|
||||
* Process the application given a request method and URI
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 MiB |
@ -1,22 +0,0 @@
|
||||
================
|
||||
``The database``
|
||||
================
|
||||
|
||||
.. contents::
|
||||
|
||||
About the container
|
||||
--------------------
|
||||
|
||||
The database container is created in two stages to bypass some limitations with docker, firstly a new image will be created based on the Dockerfile which will be based on mysql 5.7 and it'll be passed the .sql scripts to initialize the database as well as a config file to configure the port that will be exposed.
|
||||
|
||||
Initializing
|
||||
-------------
|
||||
When the database is being created as an image it'll take all the scripts in the **/docker-entrypoint-initdb.d** directory and execute them in alphabetical order which will result in the database with its tables and initial data being created.
|
||||
|
||||
Accession
|
||||
----------
|
||||
The newly created container will have two users *root** and **sloth** both of which will have the password **12345678** and it'll be accessible in the port 3307
|
||||
|
||||
Persistence
|
||||
-----------
|
||||
A volume containing the data from **/var/lib/mysql** will be created to persist the information, once its created running the container build again will execute the starting scripts
|
@ -1,99 +0,0 @@
|
||||
================
|
||||
Documentation
|
||||
================
|
||||
|
||||
.. contents::
|
||||
|
||||
Requirements
|
||||
----------------------------------
|
||||
Funtional:
|
||||
- A user name and password auth
|
||||
- Encrypted sensitive data
|
||||
- The employee need to have their full name captured
|
||||
- The last name must tolerate being null
|
||||
- An email will be needed for the employee
|
||||
- The email format must be formated
|
||||
- Employees will need a phone number
|
||||
- Searching employees despite the encryption
|
||||
- Employees must have a unique code to reference them
|
||||
- Being able to modify the name, email and phone values of already existing employees
|
||||
- Having the values for the different payments parametrized
|
||||
- Allowing for employees to perform other roles during their work day
|
||||
- Only for the auxiliary personnel
|
||||
- Taking into account only the current month for the salary
|
||||
- Reducing the taxes for the salary
|
||||
- If it goes beyond the threshold a different percentage is paid in taxes
|
||||
- The way the extra tax is handled should be parametrized
|
||||
|
||||
|
||||
Funtional:
|
||||
- Session management
|
||||
- Data integrity
|
||||
- Data security
|
||||
- Accessible through web
|
||||
- Containerized
|
||||
|
||||
Software behaivor
|
||||
-----------------
|
||||
In:
|
||||
- Employee details
|
||||
- First name
|
||||
- Middle name
|
||||
- Last name
|
||||
- Birth date
|
||||
- Email
|
||||
- Phone number
|
||||
- Work per day
|
||||
- Number of deliveries
|
||||
- Rol performed
|
||||
Process:
|
||||
- Register a new employee
|
||||
- Modify employee
|
||||
- Search employee
|
||||
- Add new work day for employee
|
||||
- Calculate monthly payment for employee
|
||||
|
||||
Out:
|
||||
- Upon registering
|
||||
- Employee code
|
||||
- In the work days registry
|
||||
- Raw salary for the the month
|
||||
- Taxes discounted
|
||||
- Real salary for the month
|
||||
- Vouchers (if applicable)
|
||||
|
||||
Calculating the monthly salary
|
||||
--------------------------------
|
||||
.. image:: https://raw.githubusercontent.com/PootisPenserHere/payroll_manager/master/documentation/calculatingSalary.bmp
|
||||
|
||||
Tests cases
|
||||
-----------------
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| Id | Description | Input | Expected output |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 1 | Displaying current salary for the outgoing month | Selecting an employee from the search field | On the right side of the window a break down of the employee's salary for the month will be displayed |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 2 | Submitting incomplete form | All of the input but one of the fields | An error shown in a red modal describing the missing field |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
| 3 | Altering the sent data to change the performed rol to one that can't be done by the employee | A employee other than aux performing a different rol than their own | An error displaying that the employee can't perform that task |
|
||||
+----+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Executed tests
|
||||
---------------
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| Id | Description | Result | What went wrong? |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 1 | Displaying current salary for the outgoing month | When the employee was selected the current salary was loaded succesfully | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 2 | Submitting incomplete form | Got the error "The number of deliveries cannot be empty or 0" | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
| 3 | Altering the sent data to change the performed rol to one that can't be done by the employee | Got the error "The selected rol can't be done by this type of employee" | |
|
||||
+----+----------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+------------------+
|
||||
|
||||
Tools
|
||||
----------------------------------
|
||||
The following tools and software were used:
|
||||
- phpstorm
|
||||
- git
|
||||
- docker && docker-compose
|
||||
- Ubuntu 16
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 MiB |
Loading…
Reference in New Issue
Block a user