Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
fix so that login handlers run after registration
Browse files Browse the repository at this point in the history
  • Loading branch information
typerandom committed Jul 14, 2016
1 parent 7afa483 commit 6839124
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/helpers/login-with-oauth-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function loginWithOAuthProvider(options, req, res) {
});
}

function continueWithHandlers(preHandler, postHandler) {
function continueWithHandlers(preHandler, postHandler, onCompleted) {
preHandler(options, req, res, function (err) {
if (err) {
return oauth.errorResponder(req, res, err);
Expand All @@ -51,20 +51,22 @@ module.exports = function loginWithOAuthProvider(options, req, res) {
return oauth.errorResponder(req, res, err);
}

continueWithTokenExchange();
onCompleted();
});
}

continueWithTokenExchange();
onCompleted();
});
}

if (preRegistrationHandler && providerAccountResult.created) {
return continueWithHandlers(preRegistrationHandler, postRegistrationHandler);
return continueWithHandlers(preRegistrationHandler, postRegistrationHandler, function () {
continueWithHandlers(preLoginHandler, postLoginHandler, continueWithTokenExchange);
});
}

if (preLoginHandler && !providerAccountResult.created) {
return continueWithHandlers(preLoginHandler, postLoginHandler);
if (preLoginHandler) {
return continueWithHandlers(preLoginHandler, postLoginHandler, continueWithTokenExchange);
}

continueWithTokenExchange();
Expand Down

0 comments on commit 6839124

Please sign in to comment.