Answer the question
In order to leave comments, you need to log in
How to remove constant duplication of code for checking access rights?
Hello!
I have two kinds of checks:
1) Is the user logged in to interact with the page;
2) Does the user own the object on which he wants to carry out the operation of deleting, editing, etc.;
The first one was very easy for me. My project is built on CodeIgniter, before executing the controller method, I run a hook - where the necessary check goes in it. I did it through annotations, the controller method has a dock comment:
/**
* Удаление объекта
*
* @auth_required
*/
public function remove_object($object_id)
if ($object->getOwner()->getId() != $this->session->userdata('user_id'))
show_404();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question