Throw more errors and cleanup some unmerged code
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user