summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2019-03-05 04:45:57 +0100
committerJannik Schönartz2019-03-05 04:45:57 +0100
commitf4aef09dbbb49270599487b40429f23fdc9ea6d2 (patch)
tree060150d83ec5feefa8d8970e7b8c3ccb077913e0
parent[webapp] migrate from vue cli 2 to vue cli 3 (diff)
downloadbas-f4aef09dbbb49270599487b40429f23fdc9ea6d2.tar.gz
bas-f4aef09dbbb49270599487b40429f23fdc9ea6d2.tar.xz
bas-f4aef09dbbb49270599487b40429f23fdc9ea6d2.zip
[server/authentication] Fix api syntax and eslint
-rw-r--r--server/api/authentication.js1
-rw-r--r--server/api/setup.js2
-rw-r--r--server/lib/authentication.js2
3 files changed, 2 insertions, 3 deletions
diff --git a/server/api/authentication.js b/server/api/authentication.js
index 73ab822..2ac8f46 100644
--- a/server/api/authentication.js
+++ b/server/api/authentication.js
@@ -1,6 +1,5 @@
/* global __appdir */
const path = require('path')
-var db = require(path.join(__appdir, 'lib', 'sequelize'))
var express = require('express')
const { decorateApp } = require('@awaitjs/express')
var noAuthRouter = decorateApp(express.Router())
diff --git a/server/api/setup.js b/server/api/setup.js
index daade25..228229a 100644
--- a/server/api/setup.js
+++ b/server/api/setup.js
@@ -18,7 +18,7 @@ noAuthRouter.get('/status', (req, res) => {
noAuthRouter.postAsync('/', async (req, res) => {
const body = req.body
const users = await db.user.findAll()
- if (users.length > 0) res.status(403).send({ status: 'USERTABLE_NOT_EMPTY', error_message: 'The user table is not empty, unauthorized creation is forbidden.' })
+ if (users.length > 0) res.status(403).send({ error: 'USERTABLE_NOT_EMPTY', message: 'The user table is not empty, unauthorized creation is forbidden.' })
else {
const result = await authentication.signup(body)
const code = result.code
diff --git a/server/lib/authentication.js b/server/lib/authentication.js
index 58ae73c..87fb02e 100644
--- a/server/lib/authentication.js
+++ b/server/lib/authentication.js
@@ -169,7 +169,7 @@ async function verifyHash (password, hash, userId) {
// Hash will be a Buffer of length SecurePassword.HASH_BYTES.
if (hash.length !== securePassword.HASH_BYTES) return { code: 500, error: 'DATABASE_HASH_INVALID', message: 'The hash in the database is corrupted.' }
// Password must be a Buffer of length SecurePassword.PASSWORD_BYTES_MIN - SecurePassword.PASSWORD_BYTES_MAX.
- if (password.length < securePassword.PASSWORD_BYTES_MIN || password.length > securePassword.PASSWORD_BYTES_MAX) return { code: 401, error: 'PASSWORD_INVALID', message: 'The provided password has an invalid length.' }
+ if (password.length < securePassword.PASSWORD_BYTES_MIN || password.length > securePassword.PASSWORD_BYTES_MAX) return { code: 401, error: 'PASSWORD_INVALID', message: 'The provided password is invalid.' }
// Verification of the password. Rehash if needed.
try {