aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/auth/registerPOST.js
diff options
context:
space:
mode:
authorPitu <[email protected]>2018-09-17 04:55:42 -0300
committerPitu <[email protected]>2018-09-17 04:55:42 -0300
commitf2c885b718528d42df412e612520fb471c46d0bd (patch)
tree8841d063055b6a3ce9abdbd1e3482d8557996f4f /src/api/routes/auth/registerPOST.js
parentChanges (diff)
downloadhost.fuwn.me-f2c885b718528d42df412e612520fb471c46d0bd.tar.xz
host.fuwn.me-f2c885b718528d42df412e612520fb471c46d0bd.zip
Commented all the code
Diffstat (limited to 'src/api/routes/auth/registerPOST.js')
-rw-r--r--src/api/routes/auth/registerPOST.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/routes/auth/registerPOST.js b/src/api/routes/auth/registerPOST.js
index dad45fd..d3532f4 100644
--- a/src/api/routes/auth/registerPOST.js
+++ b/src/api/routes/auth/registerPOST.js
@@ -24,9 +24,15 @@ class registerPOST extends Route {
return res.status(400).json({ message: 'Password must have 6-64 characters' });
}
+ /*
+ Make sure the username doesn't exist yet
+ */
const user = await db.table('users').where('username', username).first();
if (user) return res.status(401).json({ message: 'Username already exists' });
+ /*
+ Hash the supplied password
+ */
let hash;
try {
hash = await bcrypt.hash(password, 10);
@@ -36,6 +42,9 @@ class registerPOST extends Route {
return res.status(401).json({ message: 'There was a problem processing your account' });
}
+ /*
+ Create the user
+ */
const now = moment.utc().toDate();
await db.table('users').insert({
username,