Removed unused Promise resolves
This commit is contained in:
@@ -18,8 +18,8 @@ class UserSecurity {
|
|||||||
} else if (clearPassword.trim() === "") {
|
} else if (clearPassword.trim() === "") {
|
||||||
throw new Error("The password is empty.");
|
throw new Error("The password is empty.");
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve()
|
return this.userRepository
|
||||||
.then(() => this.userRepository.create(user))
|
.create(user)
|
||||||
.then(() => UserSecurity.hashPassword(clearPassword))
|
.then(() => UserSecurity.hashPassword(clearPassword))
|
||||||
.then(hash => this.userRepository.changePassword(user, hash));
|
.then(hash => this.userRepository.changePassword(user, hash));
|
||||||
}
|
}
|
||||||
@@ -32,8 +32,8 @@ class UserSecurity {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
login(user, clearPassword) {
|
login(user, clearPassword) {
|
||||||
return Promise.resolve()
|
return this.userRepository
|
||||||
.then(() => this.userRepository.retrieveHash(user))
|
.retrieveHash(user)
|
||||||
.then(hash => UserSecurity.compareHashes(hash, clearPassword))
|
.then(hash => UserSecurity.compareHashes(hash, clearPassword))
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw new Error("Incorrect username or password.");
|
throw new Error("Incorrect username or password.");
|
||||||
@@ -64,6 +64,8 @@ class UserSecurity {
|
|||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const saltRounds = 10;
|
const saltRounds = 10;
|
||||||
bcrypt.hash(clearPassword, saltRounds, (error, hash) => {
|
bcrypt.hash(clearPassword, saltRounds, (error, hash) => {
|
||||||
|
if (error) reject(error);
|
||||||
|
|
||||||
resolve(hash);
|
resolve(hash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user