aboutsummaryrefslogtreecommitdiffstats
path: root/mutations.js
diff options
context:
space:
mode:
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)
}
},