A simple update profile interceptor

I’m trying to write a very simple interceptor that determines if the user has updated their contact information. For some reason I’m getting a redirect loop. The interception point is the last in the config list. I tried both post and preevent. Thanks for any help.

component name=“profileUpdate” output=“false” extends=“coldbox.system.interceptor”
{
function preEvent(event,interceptData)
{
if(DateDiff(‘d’,lastProfileUpdate,now()) gt 45)
setNextEvent(“general.contactEdit”);
return false;
}

}

I would use the preProcess, reason being is that when you setNextEvent, and you have preEvent your trapping it in a loop as you have found out. So the only other solution is to use it before the event and go for the preProcess.

preProccess seems to still causes the issue. I just added an if to say if you are in the event I know I may redirect you to then just return true.

component name=“profileUpdate” output=“false” extends=“coldbox.system.interceptor”
{
function preEvent(event,interceptData)
{
if(event.getCurrentEvent() eq “general.contactEdit”) return false;
if(DateDiff(‘d’,lastProfileUpdate,now()) gt 45)
setNextEvent(“general.contactEdit”);
return false;
}

}

I was going to suggest that, yet wasn’t sure if the preProcess ran again when the next event was set, which it does… So rather than set next event, you could use the event override instead.

Event override?

overideevent worked nicely. Thanks

Just need to remember that there is just one caveat, if you already have used the override in one preEvent, the second will never fire.

But I find it very convenient in the times when you need to redirect, and you don’t want to let the user know that you have redirected them.