Handler and ACL permissions

Notice: This thread is very old.

6 years ago

Blažek
Member | 4
+
0
-

Hi,
is it possible to manage handler permission with ACL? I followed this tutorial and everything was clear but now I need to use handler with ACL and I found nothing about it (so maybe it's nonsense… I was wondering about using action instead of that handler but handler fits to my problem (switching boolean) – better)
Thanks

6 years ago

enumag
Member | 2128
+
0
-

What do you mean by “handler”? Do you mean sth like this? (The syntax is a little bit different now.)

6 years ago

Blažek
Member | 4
+
0
-

Ah, I'm soo sorry I mixed it up… I mean handle not handler (moderators please fix title)
here is example

template.latte

<a n:href="homepage:markDone !"> Do something </a>

HomepagePresenter

public function handleMarkDone()
{
        //Do something
}

and I'm looking for something like this if it's possible

{if $user->isAllowed('Homepage', 'handle')}
        <a n:href="homepage:markDone!"> Do something </a>
{/if}

I can't figure out how to add handles into resources list…

Last edited by Blažek (2013-09-14 14:13)

6 years ago

enumag
Member | 2128
+
+1
-

Oh you mean signals… I believe the Nette-way is this (although I don't use it anymore).

{if $user->isAllowed('Homepage', 'markDone')}
        <a n:href="homepage:markDone!"> Do something </a>
{/if}
public function handleMarkDone()
{
	if (!$this->user->isAllowed('Homepage', 'markDone')) {
		throw new \Nette\Application\ForbiddenRequestException('...');
	}
	// do something
}
services:
    authorizator:
        class: Nette\Security\Permission
        setup:
            - addRole('editor')
            - addResource('Homepage')
            - allow('editor', 'Homepage', 'markDown')

Last edited by enumag (2013-09-14 14:24)

6 years ago

Blažek
Member | 4
+
0
-

Thanks!
Working perfectly =)
sry for confusing description…