set req._isServer=true for API calls, use that as access check

This commit is contained in:
Tyler Renelle
2013-02-28 20:00:08 -05:00
parent 3017f5a592
commit 6fe375114c
2 changed files with 3 additions and 5 deletions
+1
View File
@@ -33,6 +33,7 @@ auth = (req, res, next) ->
req.user = user
req.userObj = user.get()
return res.json 401, NO_USER_FOUND if !req.userObj || _.isEmpty(req.userObj)
req._isServer = true
next()
router.get '/status', (req, res) ->
+2 -5
View File
@@ -30,9 +30,7 @@ userAccess = (store) ->
err = arguments[arguments.length - 1]
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
# TEMPORARY token check to allow api
# Must fix before release
return accept(true)
return accept(true) if derbyAuth.isServer(@)
return accept(false) if derbyAuth.bustedSession(@)
@@ -45,8 +43,7 @@ userAccess = (store) ->
return accept(true)
# Same session (user.id = this.session.userId)
if (uid is @session.userId) or derbyAuth.isServer(@)
return accept(true)
return accept(true) if uid is @session.userId
accept(false)