aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-04-17 11:07:58 -0700
committerAdam Soltys <[email protected]>2020-04-17 11:07:58 -0700
commita0e36844e119d3ea19a2c64e75bc5218aa8b4f96 (patch)
treeeab6ad46767aa2b4d0fc4546ba5c10f3c21b5a58 /routes/users.js
parent474d96cc5c04cba55d67c53a8ff48b8468bc99a7 (diff)
downloadcoinos-server-a0e36844e119d3ea19a2c64e75bc5218aa8b4f96.tar.gz
coinos-server-a0e36844e119d3ea19a2c64e75bc5218aa8b4f96.zip
more stats
Diffstat (limited to 'routes/users.js')
-rw-r--r--routes/users.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/routes/users.js b/routes/users.js
index 7c9bce31..514c39f5 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -23,11 +23,12 @@ const twofa = (req, res, next) => {
) {
return res.status(401).send("2fa required");
} else next();
-
};
app.get("/liquidate", async (req, res) => {
- let users = await db.User.findAll();
+ let users = await db.User.findAll({
+ include: { model: db.Account, as: "accounts" }
+ });
for (let i = 0; i < users.length; i++) {
let user = users[i];
if (!user.confidential) {
@@ -40,6 +41,15 @@ app.get("/liquidate", async (req, res) => {
user.otpsecret = authenticator.generateSecret();
await user.save();
}
+
+ if (!user.accounts.length) {
+ await db.Account.create({
+ user_id: user.id,
+ asset: config.liquid.btcasset,
+ balance: user.balance,
+ pending: 0
+ });
+ }
}
res.end();
});
@@ -84,7 +94,8 @@ app.post("/register", async (req, res) => {
GB: "GBP"
};
- if (!config.ipstack || ip.startsWith("127") || ip.startsWith("192")) user.currency = "CAD";
+ if (!config.ipstack || ip.startsWith("127") || ip.startsWith("192"))
+ user.currency = "CAD";
else {
let info = await axios.get(
`http://api.ipstack.com/${ip}?access_key=${config.ipstack}`
@@ -92,7 +103,7 @@ app.post("/register", async (req, res) => {
user.currency = countries[info.data.country_code] || "USD";
}
- user.currencies = [...new Set([user.currency, 'CAD', 'USD', 'JPY'])];
+ user.currencies = [...new Set([user.currency, "CAD", "USD", "JPY"])];
user.otpsecret = authenticator.generateSecret();
addresses[user.address] = user.username;