aboutsummaryrefslogtreecommitdiffstats
path: root/mutations.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2018-02-16 20:57:38 -0800
committerAdam Soltys <[email protected]>2018-02-16 20:57:38 -0800
commit5441b2fdd310153774eed6e335408253606a4d78 (patch)
treeda80ddffaf4ff7b382e6bb3f5a0895e654d05fd4 /mutations.js
parent0e974940310ea819cba2d6d8d5f5aa48469e35b5 (diff)
downloadcoinos-server-5441b2fdd310153774eed6e335408253606a4d78.tar.gz
coinos-server-5441b2fdd310153774eed6e335408253606a4d78.zip
user validation
Diffstat (limited to 'mutations.js')
-rw-r--r--mutations.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/mutations.js b/mutations.js
index 1d716e78..70e5e300 100644
--- a/mutations.js
+++ b/mutations.js
@@ -31,8 +31,12 @@ module.exports = (db, gqltypes, lnrpc) => {
}
},
resolve: async (root, { user }) => {
+ let exists = await db['User'].count({ where: { username: user.username } })
+ if (exists) throw new Error('Username taken')
+
user.address = (await lnrpc.newAddress({ type: 1 }, lnrpc.meta)).address
user.password = await bcrypt.hash(user.password, 1)
+ user.balance = 0
return db['User'].create(user)
}
},