Throw more errors and cleanup some unmerged code

This commit is contained in:
2019-07-26 21:55:59 +02:00
parent 23f9911237
commit 04ba094a14
4 changed files with 12 additions and 30 deletions

View File

@@ -33,7 +33,7 @@ class Token {
let username = null;
const token = jwt.verify(jwtToken, secret, { clockTolerance: 10000 })
if (token.username === undefined)
if (token.username === undefined || token.username === null)
throw new Error('Malformed token')
username = token.username

View File

@@ -21,7 +21,7 @@ class UserSecurity {
return Promise.resolve()
.then(() => this.userRepository.create(user))
.then(() => UserSecurity.hashPassword(clearPassword))
.then(hash => this.userRepository.changePassword(user, hash));
.then(hash => this.userRepository.changePassword(user, hash))
}
}
@@ -61,7 +61,7 @@ class UserSecurity {
*/
static hashPassword(clearPassword) {
return new Promise((resolve) => {
const salatRounds = 10;
const saltRounds = 10;
bcrypt.hash(clearPassword, saltRounds, (error, hash) => {
resolve(hash);
});