Hi guys,
I found the solution. I don't know if this is the best way, but it's working pretty good! I've changed 2 files.
STEP 1 - FrontController.php
Where you find this:
if ($this->auth AND !$cookie->isLogged($this->guestAllowed)){
Tools::redirect('authentication.php'.($this->authRedirection ? '?back='.$this->authRedirection : ''));
}
change for:
if ($this->auth AND !$cookie->isLogged($this->guestAllowed)){
if ($this->authRedirection === 'back') {
$this->authRedirection = Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']));
}
Tools::redirect('authentication.php'.($this->authRedirection ? '?back='.$this->authRedirection : ''));
}
The conditional ($this->authRedirection === 'back') will be used in the ProductController.php or wherever you want.
STEP 2 - ProductController.php
I put new public var to the Class
public $auth = true;
public $authRedirection = 'back';
When you do that, every time when the user is not logged, he will be redirect to Autentication, so he need to log in and then he will be redirect to the previous page.
I've made just for the Product, but you can do for the Category, and everything else. You just need to do the 2nd Step again.
I hope I helped!
If you have a better solution, please write back!