Skip to content

Commit

Permalink
Edit login
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek committed Apr 1, 2020
1 parent c682d2c commit 81cee17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions app/Model/FunctionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Nette;
use App\Model\DatabaseManager;
use App\Model\ThisSensorManager;
use Nette\Security\User;
use Nette\Security\User;



class FunctionManager
Expand All @@ -16,26 +17,30 @@ class FunctionManager
private $databaseManager;
private $request;
private $thisSensorManager;
private $user;




public function __construct(Nette\Database\Context $database, DatabaseManager $databaseManager, Nette\Http\Request $request, ThisSensorManager $thisSensorManager)
public function __construct(Nette\Database\Context $database, DatabaseManager $databaseManager, Nette\Security\User $user,Nette\Http\Request $request, ThisSensorManager $thisSensorManager)
{
$this->databaseManager = $databaseManager;
$this->request = $request;
$this->thisSensorManager = $thisSensorManager;
$this->database = $database;
$this->user = $user;
}

/**
* Check if the user is logged in
*/
public function checkLogin()
{
if (!$this->getUser()->isLoggedIn()) {
$this->redirect('Sign:in');
if (!$this->user->isLoggedIn()) {
$this->component->redirect('Sign:in');
}
}

}


}
5 changes: 3 additions & 2 deletions app/Presenters/SensorsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public function renderEdit($name)
{
if (!$this->getUser()->isLoggedIn()) {
$this->redirect('Sign:in');
$this->flashMessage("Nemáš dostatečné oprávnění, je nutné se přihlásit", 'error');
}

$this->template->settings = $this->databaseManager->getTitleSettings();
Expand All @@ -252,10 +253,10 @@ public function renderEdit($name)

public function renderDelete($name)
{
//$this->functionManager->checkLogin();
if (!$this->getUser()->isLoggedIn()) {
$this->redirect('Sign:in');
}
}


$this->template->settings = $this->databaseManager->getTitleSettings();

Expand Down
3 changes: 2 additions & 1 deletion app/config/common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ services:
- App\Model\DatabaseManager
- App\Model\DataManager
- App\Model\ThisSensorManager
- App\Model\FunctionManager
- App\Model\FunctionManager

0 comments on commit 81cee17

Please sign in to comment.