diff options
| author | Adam Soltys <[email protected]> | 2018-03-05 17:32:22 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-03-05 17:32:22 -0800 |
| commit | 9a5bbac84fe801c64945056fc489804f004d0bf2 (patch) | |
| tree | 3242f67ee721eea095357ddfc785154ac14f6c5e /mutations.js | |
| parent | 006de4a925945de288073aab2eed71cb03e8c69f (diff) | |
| download | coinos-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.js | 5 |
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') |
