.then(compare()) <--- here is the problem
The then
method does expect a function which returns another promise [or a plain value], so you would need to pass compare
without calling it. If you need to specify the arguments, use a wrapper function expression:
User.findByEmail(email)
.then(function(user) {
return compare(/* magic */);
}).…