Restore AppController

This commit is contained in:
Christine Slotty 2020-07-10 13:47:58 +02:00
parent a27a5af25f
commit 994fc42fac

View File

@ -54,28 +54,6 @@ public function initialize()
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
<<<<<<< Updated upstream
'loginAction' => [
'controller' => 'ServerUsers',
'action' => 'login'
],
'loginRedirect' => [
'controller' => 'Transactions',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Pages',
'action' => 'display',
'gradido'
],
'authenticate' => [
'all' => ['userModel' => 'ServerUsers'],
'Form' => [
'userModel' => 'ServerUsers',
]
]
=======
'loginAction' => [
'controller' => 'ServerUsers',
'action' => 'login'
@ -159,6 +137,8 @@ public function initialize()
} else {
$this->loginServerUrl = Router::url('/', true);
}
}
protected function requestLogin()
@ -178,27 +158,24 @@ if (!$session->check('client_ip')) {
if($session_id != 0) {
$userStored = $session->read('StateUser');
$transactionPendings = $session->read('Transactions.pending');
$transactionExecutings = $session->read('Transaction.executing');
if($session->read('session_id') != $session_id ||
( $userStored && (!isset($userStored['id']) || !$userStored['email_checked'])) ||
intval($transactionPendings) > 0 ||
intval($transactionExecutings) > 0 ) {
$http = new Client();
try {
$url = $loginServer['host'] . ':' . $loginServer['port'];
( $userStored && !isset($userStored['id'])) ||
intval($transactionPendings) > 0 ||
intval($transactionExecutings) > 0) {
$http = new Client();
try {
$url = $loginServer['host'] . ':' . $loginServer['port'];
$response = $http->get($url . '/login', ['session_id' => $session_id]);
$json = $response->getJson();
if(isset($json) && count($json) > 0) {
if($json['state'] === 'success') {
//echo "email checked: " . $json['user']['email_checked'] . "; <br>";
if($session->read('session_id') != $session_id ||
@ -295,8 +272,7 @@ if ($session_id != 0) {
}
*/
public function addAdminError($controller, $action, array $returnTable, $state_user_id)
{
public function addAdminError($controller, $action, array $returnTable, $state_user_id) {
if(!is_array($returnTable)) {
$this->addAdminError('AppController', 'addAdminError', ['state' => 'error', 'msg' => 'returnTable isn\'t array', 'details' => gettype($returnTable)], $state_user_id);
return false;
@ -320,27 +296,24 @@ if ($session_id != 0) {
if(!$adminErrorTable->save($adminErrorEntity)) {
$this->Flash->error(
__('Serious error, couldn\'t save to db, please write the admin: ' . $this->getAdminEmailLink()),
['escape' => false]
);
['escape' => false]);
}
return true;
}
public function getAdminEmailLink($text = '')
{
public function getAdminEmailLink($text = '') {
$serverAdminEmail = Configure::read('ServerAdminEmail');
return '<a href="mailto:' . $serverAdminEmail . '">'. $serverAdminEmail . '</a>';
}
public function returnJsonEncoded($json)
{
public function returnJsonEncoded($json) {
$this->autoRender = false;
$response = $this->response->withType('application/json');
return $response->withStringBody($json);
}
public function returnJson($array)
{
public function returnJson($array) {
$this->autoRender = false;
$response = $this->response->withType('application/json');
return $response->withStringBody(json_encode($array));
@ -354,4 +327,5 @@ if ($session_id != 0) {
$lastDay = $lastDay->addMonth(1);
return [$firstDay, $lastDay];
}
}