The getController package method in the C:\data\htdocs\coldbox-352\system\web\services\ModuleService.cfc component cannot be accessed from C:\data\htdocs\tdcc\model\aspects\ModuleAccountRequirement.cfc.
I’ve created an AOP aspect. Woo Hoo. It worked in my initial tests, but as I expected to have access to some coldbox objects / settings, when I added things I use all over other classes, I encountered the above error when trying to inject the moduleService object.
The apsect (bound by regex to any handler in any module) is to be designed to:
- check the current module being interacted with
- check the sessionstorage object for a particular value (to see if an “account” is selected)
- if the value is present, the access to the module (handler/action) is permitted
- if the value is not present, the access is not permitted and the user is redirected to the home page
Of course, taking suggestions on better ways to do this, but my injection of the modelService (coldbox:moduleService) to get the current module AND to get the current event context fails. I initially take that to mean that at the time this class is instantiated in the process, the objects I need are not available.
Can someone clear up this assumption for me or tell me what I might be missing before I try to start hacking it? I supposed that the init() method could use some additional arguments and I could pass in the controller (not that I’m entirely certain of how to do that) but I would rather not (or more to the point, assumed I did not have to since I can properly inject sessionstorage and wirebox).