Question

There are business cases where specific actions or requests 'must' be followed by a finishing action or request.

An example we are all familiar with is the requirement to log-in to access secure areas.

This may include cases where a certain event or problem has occurred and must be immediately addressed. This would be enforced by the entire system redirecting a user to a page, and only a specific set of continuation requests are allowed.

Now I do know ways to implement this in Symfony2 (add request listeners and redirect when required), however, currently I do not have a full grasp of the best practice to do this, my main concern is how to safely specify which actions count as valid continuations.

What I am looking for is either a) the best methodology to deal with this, or b) details on any existing bundles or features already built into Symfony2 that are designed to do this.

I am a bit worried that I may have answered by own question when I mentioned the log-in system, however I have yet to study the internal workings of Symfony2's Security Bundle to determine whether the code is reusable.

Was it helpful?

Solution

When a request ends another come just after, right ? Instead of doing things at the end of the request you could do stuff at the beginning of the other request. Then you can check if the user can access application, etc ... see security documentation. Does it help ?

Generally doing stuff at the end of the request is not a common practice, but you can (see terminate event), Symfony2 uses this event to send emails.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top