Refactored authentication layer for controllers