Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mental-Block
Copy link

removed a bunch of if statements in flow in favour of implementing strategy pattern for different auth flow methods. all passes test.

Copy link

vercel bot commented Jun 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2025 6:34am

Copy link
Contributor

@Copilot Copilot AI left a 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,
Copy link
Preview

Copilot AI Jul 22, 2025

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.

Comment on lines +290 to +293
return finishMailOTPFlow(s, ctx, request)
}

func finishOCIDFlow(s Service, ctx context.Context, request RegistrationFinishRequest) (*RegistrationFinishResponse, error) {
Copy link
Preview

Copilot AI Jul 22, 2025

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.

Suggested change
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.

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