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

Support for multiple distinct instances, as in Passport itself #186

Merged
merged 2 commits into from
Apr 15, 2023

Conversation

boutell
Copy link
Contributor

@boutell boutell commented Apr 7, 2023

Thanks for creating and maintaining this module!

In our application, it is necessary to have separate instances of Passport itself. Passport supports this: the default export is an instance, which makes sense for most projects, but there is a "Passport" property on that instance as well. This is a constructor that can be used to make a separate and distinct instance of Passport that doesn't share any configuration with the default one (or any others).

In this PR, I've contributed the same feature for passport-oauth2-refresh. I believe the test coverage shows the functionality hasn't changed.

Thanks for taking a look, and by all means let me know if any changes are needed etc.

@fiznool
Copy link
Owner

fiznool commented Apr 7, 2023

Thank you for your contribution! I am away for the Easter break but please nudge me if I haven't looked at it by the end of next week.

Copy link
Owner

@fiznool fiznool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this. I've added a couple of suggestions for improvement.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be included in these code changes?

CHANGELOG.md Outdated
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.2.0] - 2023-04-06
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to Unreleased as we don't have a definitive version number or release date yet.

Suggested change
## [2.2.0] - 2023-04-06
## [Unreleased]

CHANGELOG.md Outdated
Comment on lines 10 to 13
- In addition to exporting an object that can be immediately used,
just as before, we have added an `AuthTokenRefresh` property. This is a
constructor that can be invoked to create a distinct instance, for
applications that require more than one passport instance. (Passport has the same feature.)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this more concise. How about the following:

Suggested change
- In addition to exporting an object that can be immediately used,
just as before, we have added an `AuthTokenRefresh` property. This is a
constructor that can be invoked to create a distinct instance, for
applications that require more than one passport instance. (Passport has the same feature.)
- Added a new named export `AuthTokenRefresh`. This is a
constructor that can be invoked to create a distinct instance, for
applications that require more than one Passport instance.

@boutell
Copy link
Contributor Author

boutell commented Apr 14, 2023

Looking at the prototype idea, I saw your point but figured it would be more maintainable in the long run to use class syntax to express that, and that seems to have turned out well in this newest revision. In practice it's the same. Let me know what you think.

I tried renaming "_strategies" to "strategies", but right away that broke tests that worked without modification before. Sure, it's a private property and the tests are a special case, but I thought "this is probably meant to be a private property, but if I can avoid maybe breaking someone else's code just by leaving a name unchanged..." and left it unchanged.

I took your suggestions directly on everything else.

Thanks, let me know what you think!

@boutell boutell requested a review from fiznool April 14, 2023 12:47
Copy link
Owner

@fiznool fiznool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for this!

@fiznool fiznool merged commit b8e5e06 into fiznool:master Apr 15, 2023
@fiznool
Copy link
Owner

fiznool commented Apr 15, 2023

Published as v2.2.0

@boutell
Copy link
Contributor Author

boutell commented Apr 16, 2023

Thanks so much!

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 this pull request may close these issues.

2 participants