aboutsummaryrefslogtreecommitdiffstats
path: root/mutations.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2018-03-05 17:32:22 -0800
committerAdam Soltys <[email protected]>2018-03-05 17:32:22 -0800
commit9a5bbac84fe801c64945056fc489804f004d0bf2 (patch)
tree3242f67ee721eea095357ddfc785154ac14f6c5e /mutations.js
parent006de4a925945de288073aab2eed71cb03e8c69f (diff)
downloadcoinos-server-9a5bbac84fe801c64945056fc489804f004d0bf2.tar.gz
coinos-server-9a5bbac84fe801c64945056fc489804f004d0bf2.zip
reload user before updating balances and handle other edge cases
Diffstat (limited to 'mutations.js')
-rw-r--r--mutations.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/mutations.js b/mutations.js
index 0e8765d7..e8c26fb5 100644
--- a/mutations.js
+++ b/mutations.js
@@ -11,6 +11,8 @@ import {
GraphQLList
} from 'graphql'
+const l = console.log
+
module.exports = (db, gqltypes, lnrpc) => {
const UserInputType = new GraphQLInputObjectType({
name: 'UserInput',
@@ -31,6 +33,9 @@ module.exports = (db, gqltypes, lnrpc) => {
}
},
resolve: async (root, { user }) => {
+ if (!user.username) throw new Error('Username required')
+ if (user.password.length < 2) throw new Error('Password too short')
+
let exists = await db['User'].count({ where: { username: user.username } })
if (exists) throw new Error('Username taken')