-
Notifications
You must be signed in to change notification settings - Fork 36
implimented strategy pattern for start and finish flow #1036
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the authentication flow system by implementing the strategy pattern to replace if/else conditionals with function maps for both start and finish flows across different authentication methods (OIDC, Mail OTP, Mail Link, PassKey).
- Replaces lengthy if/else chains with strategy pattern using function maps
- Adds new OIDC constant and improves code organization
- Extracts authentication logic into dedicated strategy functions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
core/authenticate/strategy/oidc.go | Adds OIDCAuthMethod constant for strategy pattern |
core/authenticate/service.go | Major refactoring to implement strategy pattern with function maps and extract flow logic |
core/authenticate/authenticate.go | Imports OIDC constant from strategy package |
Comments suppressed due to low confidence (1)
PassKeyAuthMethod.String(): finishKeyPassFlow, | ||
MailOTPAuthMethod.String(): finishMailOTPFlow, | ||
MailLinkAuthMethod.String(): finishMailLinkFlow, | ||
OIDCAuthMethod.String(): finishOCIDFlow, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name 'finishOCIDFlow' has a typo. Should be 'finishOIDCFlow' to match the OIDC naming convention.
Copilot uses AI. Check for mistakes.
return finishMailOTPFlow(s, ctx, request) | ||
} | ||
|
||
func finishOCIDFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name 'finishOCIDFlow' has a typo. Should be 'finishOIDCFlow' to match the OIDC naming convention.
return finishMailOTPFlow(s, ctx, request) | |
} | |
func finishOCIDFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { | |
return finishOIDCFlow(s, ctx, request) | |
} | |
func finishOIDCFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) { |
Copilot uses AI. Check for mistakes.
removed a bunch of if statements in flow in favour of implementing strategy pattern for different auth flow methods. all passes test.