noir-clojure / lib-noir

A set of libraries for ring apps, including stateful sessions.
Eclipse Public License 1.0
481 stars 47 forks source link

redirecting to the originally requested URL after being redirected by a restricted route #44

Closed xavi closed 11 years ago

xavi commented 11 years ago

I was planning to use the restricted macro after reading about it in http://yogthos.net/blog/37 , but then I realized that it doesn't support a way to store the originally requested URL. For example, if a not logged-in user tries to access a page that requires to log in, then, after redirecting to the login page, and once the user is logged in, it's often desirable to redirect to the originally requested page.

I guess the rule function may be used to store this originally requested URL in the session, but it doesn't seem appropriate to me that the rule function has a side-effect like this.

Do you know of a better way to handle this?

yogthos commented 11 years ago

I think the session is the right place for this. If you'd like to do it a more structured way I would recommend checking out friend, which supports this sort of thing.

The restricted macro in lib-noir is meant to provide basic access restriction, so I don't make assumptions about having a session available.