summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJannik Schönartz2019-02-26 01:18:03 +0100
committerJannik Schönartz2019-02-26 01:18:03 +0100
commit741cf724ae6cff9b023016b9a6f42a8a9f23647c (patch)
tree49e8f95b7d88e8dc069a5d41e540c3160d6bc018 /server
parent[webapp] small ui fixes (diff)
downloadbas-741cf724ae6cff9b023016b9a6f42a8a9f23647c.tar.gz
bas-741cf724ae6cff9b023016b9a6f42a8a9f23647c.tar.xz
bas-741cf724ae6cff9b023016b9a6f42a8a9f23647c.zip
[webapp/setup] StartPageSetup now uses the new UserCreateForm component & small fixes
Diffstat (limited to 'server')
-rw-r--r--server/api/authentication.js4
-rw-r--r--server/lib/authentication.js2
2 files changed, 3 insertions, 3 deletions
diff --git a/server/api/authentication.js b/server/api/authentication.js
index 050031c..18158ce 100644
--- a/server/api/authentication.js
+++ b/server/api/authentication.js
@@ -20,8 +20,8 @@ noAuthRouter.post('/logout', (req, res) => {
// Setup method for creating the initial root account.
noAuthRouter.post('/setup', (req, res) => {
db.user.findAll().then(users => {
- if (users.length > 0) res.send({ status: 'USERTABLE_NOT_EMPTY', error_message: 'The user table is not empty, unauthorized creation is forbidden.' })
- else if (req.body.username) authentication.signup(req, res)
+ if (users.length > 0) res.status(500).send({ status: 'USERTABLE_NOT_EMPTY', error_message: 'The user table is not empty, unauthorized creation is forbidden.' })
+ else if (req.body.username) return authentication.signup(req, res)
else res.send({ status: 'SUCCESS' })
})
})
diff --git a/server/lib/authentication.js b/server/lib/authentication.js
index 9c1062c..b9c87d1 100644
--- a/server/lib/authentication.js
+++ b/server/lib/authentication.js
@@ -38,7 +38,7 @@ async function signup (req, res) {
// TODO: Implement some security stuff. Not every user who call this request should be able to sign up.
var params = req.body
if (!params.username) return res.status(400).send({ auth: false, status: 'USER_MISSING', error_message: 'This service requires an username.' })
- if (validateUsername(params.username)) return res.status(400).send({ auth: false, status: 'INVALID_USERNAME', error_message: 'Username does not fullfill the requirements. (No whitespaces)' })
+ if (!validateUsername(params.username)) return res.status(400).send({ auth: false, status: 'INVALID_USERNAME', error_message: 'Username does not fullfill the requirements. (No whitespaces)' })
if (!params.password) return res.status(400).send({ auth: false, status: 'PASSWORD_MISSING', error_message: 'This services requires a password.' })
// if (!params.email) return res.status(500).send({ auth: false, status: 'EMAIL_MISSING', error_message: 'This services requires an email.' })