aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/users.coffee16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/routes/users.coffee b/src/routes/users.coffee
index 87fd0f51..cff87d62 100644
--- a/src/routes/users.coffee
+++ b/src/routes/users.coffee
@@ -1,3 +1,4 @@
+Promise = require('bluebird')
db = require("../redis")
config = require("../config")
bcrypt = require('bcryptjs')
@@ -10,6 +11,21 @@ module.exports = (sessions) ->
if obj? then res.write('true') else res.write('false')
res.end()
)
+
+ index: (req, res) ->
+ result = 'users': []
+ db.keysAsync("user:*").then((users) ->
+ Promise.all(users.map((key) ->
+ db.hgetallAsync(key).then((user) ->
+ delete user['password']
+ result.users.push(user)
+ )
+ ))
+ ).then(->
+ res.writeHead(200, {"Content-Type": "application/json"});
+ res.write(JSON.stringify(result))
+ res.end()
+ )
json: (req, res) ->
res.end() unless req.params.user