Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jun 11, 2024
1 parent 89b0a58 commit 748130a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions selfservice/flow/login/strategy_form_hydrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type FormHydrator interface {

type FormHydratorOptions struct {
IdentityHint *identity.Identity
Identifier string
}

type FormHydratorModifier func(o *FormHydratorOptions)
Expand All @@ -33,6 +34,12 @@ func WithIdentityHint(i *identity.Identity) FormHydratorModifier {
}
}

func WithIdentifier(i string) FormHydratorModifier {
return func(o *FormHydratorOptions) {
o.Identifier = i
}
}

func NewFormHydratorOptions(modifiers []FormHydratorModifier) *FormHydratorOptions {
o := new(FormHydratorOptions)
for _, m := range modifiers {
Expand Down
6 changes: 6 additions & 0 deletions selfservice/flow/login/strategy_form_hydrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ func TestWithIdentityHint(t *testing.T) {
opts := NewFormHydratorOptions([]FormHydratorModifier{WithIdentityHint(expected)})
assert.Equal(t, expected, opts.IdentityHint)
}

func TestWithIdentifier(t *testing.T) {
expected := "identifier"
opts := NewFormHydratorOptions([]FormHydratorModifier{WithIdentifier(expected)})
assert.Equal(t, expected, opts.Identifier)
}
1 change: 1 addition & 0 deletions selfservice/strategy/idfirst/strategy_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (s *Strategy) Login(w http.ResponseWriter, r *http.Request, f *login.Flow,

// Add identity hint
opts = append(opts, login.WithIdentityHint(identityHint))
opts = append(opts, login.WithIdentifier(p.Identifier))

for _, ls := range s.d.LoginStrategies(r.Context()) {
populator, ok := ls.(login.FormHydrator)
Expand Down

0 comments on commit 748130a

Please sign in to comment.