From 9a5bbac84fe801c64945056fc489804f004d0bf2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 5 Mar 2018 17:32:22 -0800 Subject: reload user before updating balances and handle other edge cases --- mutations.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mutations.js') 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') -- cgit v1.2.3