diff options
| author | Adam Soltys <[email protected]> | 2018-02-16 20:57:38 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-02-16 20:57:38 -0800 |
| commit | 5441b2fdd310153774eed6e335408253606a4d78 (patch) | |
| tree | da80ddffaf4ff7b382e6bb3f5a0895e654d05fd4 /mutations.js | |
| parent | 0e974940310ea819cba2d6d8d5f5aa48469e35b5 (diff) | |
| download | coinos-server-5441b2fdd310153774eed6e335408253606a4d78.tar.gz coinos-server-5441b2fdd310153774eed6e335408253606a4d78.zip | |
user validation
Diffstat (limited to 'mutations.js')
| -rw-r--r-- | mutations.js | 4 |
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) } }, |
