diff --git a/api-payroll/public/html/landing.php b/api-payroll/public/html/landing.php
index eddf31b..cfbe622 100644
--- a/api-payroll/public/html/landing.php
+++ b/api-payroll/public/html/landing.php
@@ -1,12 +1,3 @@
-
-
@@ -40,10 +31,6 @@ if(!isset($_SESSION['userName'])){
Management
-
-
- Change password
-
-
diff --git a/api-payroll/public/html/login.php b/api-payroll/public/html/login.php
index 15a00e4..46f8e64 100644
--- a/api-payroll/public/html/login.php
+++ b/api-payroll/public/html/login.php
@@ -1,12 +1,3 @@
-
-
diff --git a/api-payroll/public/js/landing.js b/api-payroll/public/js/landing.js
index 42a8bb5..9bb9850 100644
--- a/api-payroll/public/js/landing.js
+++ b/api-payroll/public/js/landing.js
@@ -13,12 +13,15 @@ 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) {
- $('#modalError500').modal('show');
+ $('#modalServerResponseError').modal('show');
+ document.getElementById('modalResponseError').innerHTML = responseText['message'];
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
@@ -59,12 +62,15 @@ function loadView(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) {
- $('#modalError500').modal('show');
+ $('#modalServerResponseError').modal('show');
+ document.getElementById('modalResponseError').innerHTML = responseText['message'];
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
diff --git a/api-payroll/src/application/EmployeeApplication.php b/api-payroll/src/application/EmployeeApplication.php
index 1deb41d..3391ea3 100644
--- a/api-payroll/src/application/EmployeeApplication.php
+++ b/api-payroll/src/application/EmployeeApplication.php
@@ -9,13 +9,28 @@ class EmployeeApplication{
private $cryptographyService;
private $asserts;
private $settings;
+ private $session;
- function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
+ /**
+ * EmployeeApplication constructor.
+ * @param $employeeSettings
+ * @param $mysql
+ * @param $cryptographyService
+ * @param $asserts
+ * @param $session
+ * @throws Exception
+ */
+ function __construct($employeeSettings, $mysql, $cryptographyService, $asserts, $session){
$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.');
+ };
}
/**
@@ -81,7 +96,6 @@ 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 ");
}
}
diff --git a/api-payroll/src/application/SessionApplication.php b/api-payroll/src/application/SessionApplication.php
index a7f3af2..74fe3f2 100644
--- a/api-payroll/src/application/SessionApplication.php
+++ b/api-payroll/src/application/SessionApplication.php
@@ -87,6 +87,11 @@ 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.');
+ }
+
return true;
}
else{
@@ -119,10 +124,15 @@ 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.');
+ }
+
return array('status' => 'success', 'message' => 'Successfully logged out.');
}
}
diff --git a/api-payroll/src/dependencies.php b/api-payroll/src/dependencies.php
index 86a1ed8..abed60d 100644
--- a/api-payroll/src/dependencies.php
+++ b/api-payroll/src/dependencies.php
@@ -76,6 +76,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['mysql'], $c['cryptographyService'], $c['asserts'], $c['sessionApplication']);
return $employeeApplication;
};
diff --git a/api-payroll/src/settings.php b/api-payroll/src/settings.php
index e007764..165767e 100644
--- a/api-payroll/src/settings.php
+++ b/api-payroll/src/settings.php
@@ -22,7 +22,7 @@ return [
'name' => 'payroll-laziness-rocks',
'lifetime' => 10,
'path' => '/',
- 'domain' => "laziness.rocks",
+ 'domain' => null,
'secure' => false,
'httponly' => true,