From 748130a3dca08123c6e95b48107b2119d92c08d8 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:24:36 +0200 Subject: [PATCH] chore: synchronize workspaces --- selfservice/flow/login/strategy_form_hydrator.go | 7 +++++++ selfservice/flow/login/strategy_form_hydrator_test.go | 6 ++++++ selfservice/strategy/idfirst/strategy_login.go | 1 + 3 files changed, 14 insertions(+) diff --git a/selfservice/flow/login/strategy_form_hydrator.go b/selfservice/flow/login/strategy_form_hydrator.go index 9f7af50c0b9a..93d3b29460b9 100644 --- a/selfservice/flow/login/strategy_form_hydrator.go +++ b/selfservice/flow/login/strategy_form_hydrator.go @@ -23,6 +23,7 @@ type FormHydrator interface { type FormHydratorOptions struct { IdentityHint *identity.Identity + Identifier string } type FormHydratorModifier func(o *FormHydratorOptions) @@ -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 { diff --git a/selfservice/flow/login/strategy_form_hydrator_test.go b/selfservice/flow/login/strategy_form_hydrator_test.go index 64d0f0f54d6d..863a1031051d 100644 --- a/selfservice/flow/login/strategy_form_hydrator_test.go +++ b/selfservice/flow/login/strategy_form_hydrator_test.go @@ -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) +} diff --git a/selfservice/strategy/idfirst/strategy_login.go b/selfservice/strategy/idfirst/strategy_login.go index 4d6768a875f0..688771f995a7 100644 --- a/selfservice/strategy/idfirst/strategy_login.go +++ b/selfservice/strategy/idfirst/strategy_login.go @@ -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)