aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-04-24 22:46:45 -0700
committerAdam Soltys <[email protected]>2020-04-24 22:46:45 -0700
commit83f973224bad381df62774bcc058f76eab635f0c (patch)
treeef231f4490b0c9d194b8683be50c05524738903e /lib
parent306357c24d3014b55ae1cd25b954a695ea2e5cc6 (diff)
downloadcoinos-server-assets.tar.gz
coinos-server-assets.zip
Diffstat (limited to 'lib')
-rw-r--r--lib/passport.js1
-rw-r--r--lib/sockets.js1
-rw-r--r--lib/utils.js79
-rw-r--r--lib/whitelist.js8
4 files changed, 59 insertions, 30 deletions
diff --git a/lib/passport.js b/lib/passport.js
index 81f4e948..e0c2dd62 100644
--- a/lib/passport.js
+++ b/lib/passport.js
@@ -1,6 +1,5 @@
const Passport = require("passport");
const jwt = require("passport-jwt");
-const { getUser } = require("./utils");
function cookieExtractor(req) {
if (req && req.cookies) return req.cookies["token"];
diff --git a/lib/sockets.js b/lib/sockets.js
index ad7295b0..9a5457c3 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -1,6 +1,5 @@
const jwt = require("jsonwebtoken");
const io = require("socket.io");
-const { getUser } = require("./utils");
/* eslint-disable-next-line */
const pick = (O, ...K) => K.reduce((o, k) => ((o[k] = O[k]), o), {});
diff --git a/lib/utils.js b/lib/utils.js
index 7784ae5c..7b4b1668 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -1,30 +1,57 @@
const { Op } = require("sequelize");
-module.exports = {
- async getUser(username) {
- return db.User.findOne({
- include: [
- {
- model: db.Payment,
- as: "payments",
- order: [["id", "DESC"]],
- where: {
- [Op.or]: {
- received: true,
- amount: {
- [Op.lt]: 0
- }
+getUser = async username => {
+ return db.User.findOne({
+ include: [
+ {
+ model: db.Payment,
+ as: "payments",
+ order: [["id", "DESC"]],
+ where: {
+ [Op.or]: {
+ received: true,
+ amount: {
+ [Op.lt]: 0
}
- },
- limit: 12
+ }
},
- {
- model: db.Account,
- as: "accounts"
- }
- ],
- where:
- { [Op.or]: { username, id: username }}
- });
- }
-};
+ limit: 12
+ },
+ {
+ model: db.Account,
+ as: "accounts"
+ },
+ {
+ model: db.Account,
+ as: "account"
+ }
+ ],
+ where: { username },
+ });
+}
+
+getUserById = async id => {
+ return db.User.findOne({
+ include: [
+ {
+ model: db.Payment,
+ as: "payments",
+ order: [["id", "DESC"]],
+ where: {
+ [Op.or]: {
+ received: true,
+ amount: {
+ [Op.lt]: 0
+ }
+ }
+ },
+ limit: 12
+ },
+ {
+ model: db.Account,
+ as: "accounts"
+ }
+ ],
+ where: { id }
+ });
+}
diff --git a/lib/whitelist.js b/lib/whitelist.js
index e5f672b2..8af95820 100644
--- a/lib/whitelist.js
+++ b/lib/whitelist.js
@@ -1,5 +1,7 @@
whitelist = [
'id',
+'account',
+'account_id',
'unit',
'fbtoken',
'username',
@@ -7,11 +9,13 @@ whitelist = [
'symbol',
'currency',
'currencies',
-'balance',
-'pending',
'name',
'pic',
'twofa',
'liquid',
'confidential',
+'accounts',
+'payments',
+'balance',
+'pending',
]