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

Fix user extension implementation #70

Merged
merged 2 commits into from
Jun 19, 2023
Merged

Conversation

bngo92
Copy link
Contributor

@bngo92 bngo92 commented May 26, 2023

The current extension is of type Option.
This is less ergonomic for handlers that already use RequireAuthorizationLayer.

The current extension is of type Option<User>.
This is less ergonomic for handlers that already use
RequireAuthorizationLayer.
Comment on lines 131 to 133
request
.extensions_mut()
.insert(auth_cx.current_user.clone());
Copy link
Owner

@maxcountryman maxcountryman May 30, 2023

Choose a reason for hiding this comment

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

Is the idea in keeping this to preserve backwards compatibility?

I'm a little concerned it's confusing to have Option<User> and User as extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, lines 131-133 are for backwards compatibility while lines 134-136 implements the extension as described in the doc examples.

I am open to dropping lines 131-133 if you're not concerned with backwards compatibility. This change should be relatively safe as the Option<User> extension wasn't documented.

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 it's safe to drop given we're pre-1.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I have updated the pull request.

The documented user extension type is of type User but the implemented
extension is of type Option<User>.
This is less ergonomic for handlers that already use
RequireAuthorizationLayer.
@bngo92 bngo92 changed the title Add an extension for the current user of type User Fix user extension implementation Jun 18, 2023
@maxcountryman maxcountryman merged commit 45a33de into maxcountryman:main Jun 19, 2023
8 checks passed
@maxcountryman
Copy link
Owner

Thank you for putting this together!

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