Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 84240bf5de
Fetching contributors…

Cannot retrieve contributors at this time

18 lines (15 sloc) 0.579 kb
loadUser = ->
if req.headers.authorization and req.headers.authorization.search('Basic ') == 0
creds = new Buffer(req.headers.authorization.split(' ')[1], 'base64').toString()
if creds == app.config.admin
req.session.user = true
@user = !!req.session.user
next()
before loadUser
publish 'userRequired', ->
if @user
next()
else
console.log 'Unable to authenticate user ' + req.headers.authorization
response.header 'WWW-Authenticate', 'Basic realm="Admin Area"'
send 'Authentication required', 401
Jump to Line
Something went wrong with that request. Please try again.