New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup inner funcs #5

Merged
merged 1 commit into from May 5, 2017
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings

Always

Just for now

View
@@ -34,17 +34,19 @@ function errorHandler(err) {
}
function auth({username, password}) {
const userQuery = hashStringAsync(password)
.then(hashPass => ({username, hashPass}))
const loginEvent = () => auditLogAsync({event: 'login', username})
return Promise
.resolve({username, password})
.catch(errorHandler)
.then(authValidate)
.tap(() => auditLogAsync({event: 'login', username}))
.tap(loginEvent)
.then(usersModel)
.then(users => {
// Inner Promise's value will bubble all the way up
// Note: This can also be further flattened... Keep reading.
return hashStringAsync(password)
.then(hashPass => users.findOneAsync({username, passHash}))
return userQuery
.then(users.findOneAsync)
.then(userFound)
})
ProTip! Use n and p to navigate between commits in a pull request.