Passing Authentication Method to After Authenticate Functions [HIRO-385]#157
Open
tolgatolgay wants to merge 1 commit into
Open
Passing Authentication Method to After Authenticate Functions [HIRO-385]#157tolgatolgay wants to merge 1 commit into
tolgatolgay wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Hiro’s authentication-related hooks to include the authentication provider, so downstream “after authenticate” handlers and publishers can react differently based on the login method (Apple/Google/etc.).
Changes:
- Extend
Publisher.Authenticateto include anAuthProviderargument. - Extend
AfterAuthenticateFnto include anAuthProviderargument. - Introduce the
AuthProvidertype and constants, and updateSatoriPersonalizerto match the updated publisher interface.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| publisher.go | Adds provider AuthProvider to the Publisher.Authenticate interface method. |
| personalizer_satori.go | Updates SatoriPersonalizer.Authenticate signature to implement the updated Publisher interface. |
| base.go | Adds AuthProvider type/constants and extends AfterAuthenticateFn to include the provider. |
Comments suppressed due to low confidence (1)
personalizer_satori.go:246
- The new
providerparameter (andcreated) are not used in this implementation. If they’re intentionally unused, consider renaming them to_(or otherwise documenting why they’re unused) to avoid confusion for readers and to make it clear Satori auth does not currently depend on the auth provider.
func (p *SatoriPersonalizer) Authenticate(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, created bool, provider AuthProvider) {
if !p.IsPublishAuthenticateRequest() && !p.IsPublishAuthenticateRequestWithSession() {
return
}
if _, err := nk.GetSatori().Authenticate(ctx, userID, nil, nil, !p.IsPublishAuthenticateRequestWithSession()); err != nil && !errors.Is(err, runtime.ErrSatoriConfigurationInvalid) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -48,7 +48,7 @@ type PublisherEvent struct { | |||
| type Publisher interface { | |||
| // Authenticate is called every time a user authenticates with Hiro. The 'created' flag is true if this | |||
| // is a newly created user account, and each implementation may choose to handle this as it chooses. | |||
Comment on lines
+74
to
75
| type AfterAuthenticateFn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, session *api.Session, provider AuthProvider) error | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.