diff options
| author | Adam Soltys <[email protected]> | 2014-09-16 09:39:04 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2014-09-16 09:39:04 -0700 |
| commit | c257bd5ffac25ab26ca31f43af2a0607668d781f (patch) | |
| tree | e8a2fd366b5cd1980eff84d731f80958fc712c3c | |
| parent | 98bb41a55a1e8cc0770552478baa74e7512563e4 (diff) | |
| download | coinos-server-c257bd5ffac25ab26ca31f43af2a0607668d781f.tar.gz coinos-server-c257bd5ffac25ab26ca31f43af2a0607668d781f.zip | |
Check for empty transactions array
| -rw-r--r-- | routes/transactions.js | 4 | ||||
| -rw-r--r-- | routes/users.js | 2 | ||||
| -rw-r--r-- | src/routes/transactions.coffee | 4 | ||||
| -rw-r--r-- | src/routes/users.coffee | 2 |
4 files changed, 10 insertions, 2 deletions
diff --git a/routes/transactions.js b/routes/transactions.js index 28fd2418..759ec14a 100644 --- a/routes/transactions.js +++ b/routes/transactions.js @@ -25,6 +25,10 @@ }; return db.lrange("" + user + ":transactions", 0, -1, function(err, transactions) { var cb, i, txid; + if (err || !transactions.length) { + res.write(JSON.stringify(r)); + return res.end(); + } txid = function() { var x; x = transactions[i++]; diff --git a/routes/users.js b/routes/users.js index 37ce9774..46a8f8f8 100644 --- a/routes/users.js +++ b/routes/users.js @@ -121,7 +121,7 @@ if (host === 'localhost') { host += ':3000'; } - url = "" + req.protocol + "://" + req.hostname + ":3000/verify/" + token; + url = "" + req.protocol + "://" + host + "/verify/" + token; return res.render('users/welcome', { user: req.params.user, layout: 'mail', diff --git a/src/routes/transactions.coffee b/src/routes/transactions.coffee index 4578a7d8..25ccbbc9 100644 --- a/src/routes/transactions.coffee +++ b/src/routes/transactions.coffee @@ -15,6 +15,10 @@ module.exports = r = 'transactions': [] db.lrange("#{user}:transactions", 0, -1, (err, transactions) -> + if err or not transactions.length + res.write(JSON.stringify(r)) + return res.end() + txid = -> x = transactions[i++] return x if x.match(/[a-z]/i) diff --git a/src/routes/users.coffee b/src/routes/users.coffee index 307f7ab6..838ef631 100644 --- a/src/routes/users.coffee +++ b/src/routes/users.coffee @@ -88,7 +88,7 @@ module.exports = (sessions) -> db.set("token:#{token}", req.body.username) host = req.hostname host += ':3000' if host is 'localhost' - url = "#{req.protocol}://#{req.hostname}:3000/verify/#{token}" + url = "#{req.protocol}://#{host}/verify/#{token}" res.render('users/welcome', user: req.params.user, |
