Good evening. I have two modules in my application - an Auth module, and an Album module. What i did - i added the means for a user to log in or register. What i'd like to do - force any anonymous user to log in or register when he attempts to access any other actions.
All i did was save the user's data in the session variable like so:
//Zend\Session\Container;
$userSession = new Container('user');
$userSession->name = $username;
What i could do with this is i could verify at the beginning of every action of every module if there is any user data, but that would be too much copy/paste in my opinion. Is there a way to verify if the user is logged in in one place, and if not, just redirect him to the log in page without copypasting this in every action?