Skip to content
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

Promises #225

Closed
callumacrae opened this issue Apr 7, 2014 · 5 comments
Closed

Promises #225

callumacrae opened this issue Apr 7, 2014 · 5 comments

Comments

@callumacrae
Copy link

I have the following code:

    user.save()
        .then(function () {
            req.login(user, function (err) {
                if (err) {
                    next(err);
                } else {
                    auth.login(req, res);
                }
            });
        })
        .error(function (err) {
            winston.err(err);
        });

It would be nicer as:

    user.save()
        .then(function () {
            return req.login(user);
        })
        .then(function () {
            auth.login(req, res);
        })
        .error(function (err) {
            winston.err(err);
        });

If I added support for promises to passport, would you merge it?

@jaredhanson
Copy link
Owner

Would this only impact req.login?

Sent from my iPhone

On Apr 7, 2014, at 1:20 AM, Callum Macrae [email protected] wrote:

I have the following code:

user.save()
    .then(function () {
        req.login(user, function (err) {
            if (err) {
                next(err);
            } else {
                auth.login(req, res);
            }
        });
    })
    .error(function (err) {
        winston.err(err);
    });

It would be nicer as:

user.save()
    .then(function () {
        return req.login(user);
    })
    .then(function () {
        auth.login(req, res);
    })
    .error(function (err) {
        winston.err(err);
    });

If I added support for promises to passport, would you merge it?


Reply to this email directly or view it on GitHub.

@callumacrae
Copy link
Author

I think so; do any other functions accept callbacks?

On 7 Apr 2014, at 15:20, Jared Hanson [email protected] wrote:

Would this only impact req.login?

Sent from my iPhone

On Apr 7, 2014, at 1:20 AM, Callum Macrae [email protected] wrote:

I have the following code:

user.save()
.then(function () {
req.login(user, function (err) {
if (err) {
next(err);
} else {
auth.login(req, res);
}
});
})
.error(function (err) {
winston.err(err);
});
It would be nicer as:

user.save()
.then(function () {
return req.login(user);
})
.then(function () {
auth.login(req, res);
})
.error(function (err) {
winston.err(err);
});
If I added support for promises to passport, would you merge it?


Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub.

@jaredhanson
Copy link
Owner

No, that should be it. I'm not opposed. If you need to pull in a promise library, I'd prefer promise since that seems the most lightweight.

callumacrae added a commit to callumacrae/passport that referenced this issue Apr 8, 2014
dignifiedquire added a commit to dignifiedquire/passport that referenced this issue May 8, 2014
dignifiedquire added a commit to dignifiedquire/passport that referenced this issue May 8, 2014
@jaredhanson
Copy link
Owner

Closing. See comment for rationale.

@nhooey
Copy link

nhooey commented Feb 26, 2017

See issue #536 for adding promise support now that a lot of time has passed since this issue was created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants