The rails before_filter concept is closely related to connect's middleware concept, which is part of the expression. You can configure this manually by following each photo-related route using the authentication function, or use something higher level, as mentioned in TJ. Doing it manually would be just a matter of something like this (pseudo-coffenscript)
myAuthMiddleware = (req, res, next) -> if not req.session.user? res.redirect "/" else next() editPhoto = (req, res) -> .... deletePhoto = (req, res) -> .... app.use(myAuthMiddleware, func) for func in [editPhoto, deletePhoto]
What this means, use myAuthMiddleware , like before_filter for the middleware functions editPhoto and deletePhoto .
Peter Lyons Jan 13 '12 at 15:55 2012-01-13 15:55
source share