Skip to content

Instantly share code, notes, and snippets.

@seivan
Created July 24, 2011 20:09
Show Gist options
  • Save seivan/1103042 to your computer and use it in GitHub Desktop.
Save seivan/1103042 to your computer and use it in GitHub Desktop.
#router.routes(app)
app.get "/", protect, (req, res, next)->
res.send "SO YOU KNOW #{req.user}"
protect = (req, res, next) ->
console.log "I don't even get here"
if req.isAuthenticated() then req.user = "YES" else req.user "NO"
if( req.isAuthenticated() ) next()
else
req.authenticate ["twitter"], (error, authenticated) ->
if( error )
next(new Error("Problem authenticating"))
else
if( authenticated == true)
next()
else if( authenticated == false )
next(new Error("Access Denied!"))
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment