symfony2 fallback route for permission denied

Is there a way to specify a fallback route for a route if the user lacks the required role to access the requested route?

Tor example, a logged in user has access to many pages of my site. When that user requests to use a function on my site that it lacks permission for (ie needs the role ROLE_SUBSCRIBING), I would want to show a page describing the requested function, and display options for payment to become ROLE_SUBSCRIBING. Rediricting to the login form makes no sense here since the user is correctly authenticated.

Answers


Checkout http://symfony.com/doc/current/reference/configuration/security.html you want:

# app/config/security.yml
security:
    access_denied_url: /foo/error403

You can also do it per firewall:

# app/config/security.yml
security:

#...

    firewalls:
        somename:
            #...
            access_denied_url: /foo/error403

Need Your Help

iPhone: understanding field crash reports: unrecognized selector?

iphone objective-c debugging crash

A user of my app out in the field seems to having bad crash-at-app-start issues. I got him to send me the .crash files from his PC. After "symbolicating" them according to this article, I get what ...

Generic constraints and interface implementation/inheritance

c# generics

Not entirely sure how to phrase the question, because it's a "why doesn't this work?" type of query.