Skip to content

Commit

Permalink
fix: do not reset registration method
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Apr 17, 2021
1 parent 2f92a70 commit 554bb0b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion selfservice/flow/login/test/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestFlowPersister(ctx context.Context, p persistence.Persister) func(t *tes
}

return func(t *testing.T) {
_, p := testhelpers.NewNetworkUnlessExisting(t,ctx,p)
_, p := testhelpers.NewNetworkUnlessExisting(t, ctx, p)

t.Run("case=should error when the login flow does not exist", func(t *testing.T) {
_, err := p.GetLoginFlow(ctx, x.NewUUID())
Expand Down
1 change: 0 additions & 1 deletion selfservice/strategy/password/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (s *Strategy) RegisterRegistrationRoutes(_ *x.RouterPublic) {

func (s *Strategy) handleRegistrationError(_ http.ResponseWriter, r *http.Request, f *registration.Flow, p *RegistrationFormPayload, err error) error {
if f != nil {
f.UI.Nodes.Reset()
if p != nil {
for _, n := range container.NewFromJSON("", node.PasswordGroup, p.Traits, "traits").Nodes {
// we only set the value and not the whole field because we want to keep types from the initial form generation
Expand Down
3 changes: 3 additions & 0 deletions selfservice/strategy/password/registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func TestRegistration(t *testing.T) {
assert.Contains(t, gjson.Get(actual, "ui.action").String(), publicTS.URL+registration.RouteSubmitFlow, "%s", actual)
checkFormContent(t, []byte(actual), "password", "csrf_token", "traits.username", "traits.foobar")
assert.Contains(t, gjson.Get(actual, "ui.nodes.#(attributes.name==password).messages.0").String(), "data breaches and must no longer be used.", "%s", actual)

// but the method is still set
assert.Equal(t, "password", gjson.Get(actual, "ui.nodes.#(attributes.name==method).attributes.value").String(), "%s", actual)
}

var values = func(v url.Values) {
Expand Down

0 comments on commit 554bb0b

Please sign in to comment.