This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I would like some advice on the best way of doing some basic checking whenever a component is run whether it is a straight display or an ajax display. I have many components with lots of ajax methods such as onUpdate, onAddAlert, onDeleteSomething, etc as well as the usual onRun.
For all of these public methods I need to be able to ensure that some basic validation is done such as checking there is a logged in user, or that the url parameters are valid, and so on. I can add the checking and redirect if there is a problem so I can, for example, redirect, if the user is not logged in, to a login page. But all of this checking has to be done for every point where the execution cycle enters the component.
So I have tried to use onInit which can do the checking only once but there is a problem with this, the onInit cannot process a returned redirect. At least that is what all my testing has proved, I may be wrong I guess.
So my question is "What is the best way to handle common validation and perform redirection for failures?" Any suggestions?
Thank you
1-1 of 1