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

Add ability to obtain result of Authentication process #12

Merged

Conversation

martindufort
Copy link
Contributor

Closes #11.

@mattmassicotte
Copy link
Contributor

This is awesome, thank you! I will look more closely soon.

Copy link
Contributor

@mattmassicotte mattmassicotte left a comment

Choose a reason for hiding this comment

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

This is wonderful! Just had two questions about the new function type.

@@ -20,7 +20,8 @@ public enum AuthenticatorError: Error {
/// Manage state required to executed authenticated URLRequests.
public final class Authenticator {
public typealias UserAuthenticator = (URL, String) async throws -> URL

public typealias AuthenticationResult = (Login?, AuthenticatorError?) -> Void
Copy link
Contributor

Choose a reason for hiding this comment

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

Two questions for this type.

First, what do you think about making the parameter Result<Login, AuthenticatorError>? This would help to ease the optional juggling.

Second, I keep coming back to the name AuthenticationResult. What do you think about something like DidLogin or LoginHandler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Not sure why but I never use the Result type. However I think this is much better. Will make the change.

  2. I feel that there are a lot of Provider / Handler like types in the package. Do you think DidLogin would go against the naming convention? Also LoginHandler feels that you need to handle the login which is not the case. It's only a reporting mechanism.
    What about AuthenticationStatusHandler or something like that?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Great! It took me a while to warm up to Result too. And, I often now prefer throwing, since it fits in much better with concurrency. But in this case, it does seem like a good fit.

  2. Yeah, I didn't think too hard, but you are making a good point. That name works for me!

…StatusHandler

Update README.md to showcase new usage
Add new test to validate that error in AuthenticationStatusHandler is properly propagated
@mattmassicotte mattmassicotte merged commit bddf460 into ChimeHQ:main Oct 2, 2023
3 checks passed
@martindufort martindufort deleted the feature/AuthenticationResult branch October 3, 2023 18:04
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.

Obtaining user granted scopes from OAuthenticator
2 participants