Welcome Guest, Not a member yet? Register   Sign In
Is it possible to block certain functions within a controller classes?
#1

[eluser]mihu[/eluser]
I am trying to block certain functions within the controllers class base on user profile.
Is there a better way other than calling a check function within those functions.
Is it possible to do it within constructor?

Thanks,
#2

[eluser]Colin Williams[/eluser]
You could do it in the constructor, but it seems better to do it in the functions to me. That way, if conditions need to be changed for the access checks, you don't find yourself muddying the constructor with more and more conditionals.
#3

[eluser]mihu[/eluser]
I am thinking to do it via constructor + $this->uri->segment(2); instead of just within function.
Either way, I am calling a private function so I only need to take care 1 place.

Thanks for reply.
#4

[eluser]Michael Wales[/eluser]
I would call a private function from my constructor (or a library, if you plan to implement this across multiple controllers) that will verify whether the user has the rights to access a particular URI.

Essentially, you are looking to build an ACL.
#5

[eluser]mihu[/eluser]
Thanks a lot. Big Grin ... private function it is.




Theme © iAndrew 2016 - Forum software by © MyBB