This repository has been archived by the owner on Aug 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfortunately Kdyby\Events behavior is not good at all. It's necessary to register presenter or components into container, but it's against generated factories behavior. It's quite a big security hole, because if you forgot to register these classes into container, event will NOT be called... :-(
- Loading branch information
Showing
5 changed files
with
53 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
class RestrictListener extends Nette\Object implements Kdyby\Events\Subscriber { | ||
|
||
public function getSubscribedEvents() { | ||
return array( | ||
'App\AdminPresenter::onBeforeRestrictedFunctionality' => 'adminEdit', | ||
'Cntrl\PostForm::onBeforeRestrictedFunctionality' => 'controlEdit', | ||
'Cntrl\UserEditForm::onBeforeRestrictedFunctionality' => 'controlEdit', | ||
); | ||
} | ||
|
||
public function adminEdit(Nette\Application\UI\Presenter $presenter) { | ||
if (!$presenter->user->isAllowed('Admin', App\Authorizator::EDIT)) { | ||
$presenter->flashMessage('Myslím to vážně, editovat opravdu **ne**můžete!', 'danger'); | ||
$presenter->redirect('this'); | ||
return; | ||
} | ||
} | ||
|
||
public function controlEdit(Nette\Application\UI\Control $control) { | ||
if (!$control->presenter->user->isAllowed('Admin', App\Authorizator::EDIT)) { | ||
$control->presenter->flashMessage('Myslím to vážně, editovat opravdu **ne**můžete!', 'danger'); | ||
$control->presenter->redirect('this'); | ||
return; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters