-
-
Save thejh/1103067 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protect = (req, res, next) -> | |
console.log "I don't even get here" | |
req.user = if req.isAuthenticated() then "YES" else "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!" | |
app.get "/", protect, (req, res, next)-> | |
res.send "SO YOU KNOW #{req.user}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment