diff options
| author | Adam Soltys <[email protected]> | 2016-10-14 22:02:20 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2016-10-14 22:02:20 -0700 |
| commit | a4adc19e1e8cbe1e91afc5d81a5c844a8e92cb18 (patch) | |
| tree | 17cd0e8cf91e3902e4d584dc28621d4258370d80 /src/routes | |
| parent | 6f906c289422c9d655e194390bb871b2e276f326 (diff) | |
| download | coinos-server-a4adc19e1e8cbe1e91afc5d81a5c844a8e92cb18.tar.gz coinos-server-a4adc19e1e8cbe1e91afc5d81a5c844a8e92cb18.zip | |
List users
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/users.coffee | 16 |
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 |
