From 9a120fc7b5cd02f28049bad5fd978d4002f48007 Mon Sep 17 00:00:00 2001 From: splaunov Date: Wed, 22 Nov 2023 11:33:39 +0300 Subject: [PATCH] fix: sort ui nodes when `code` is added (PS-144) --- selfservice/strategy/code/strategy_registration.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/selfservice/strategy/code/strategy_registration.go b/selfservice/strategy/code/strategy_registration.go index 2f91b558686b..481fe818cd89 100644 --- a/selfservice/strategy/code/strategy_registration.go +++ b/selfservice/strategy/code/strategy_registration.go @@ -129,6 +129,13 @@ func (s *Strategy) Register(w http.ResponseWriter, r *http.Request, f *registrat return s.handleRegistrationError(w, r, f, &p, err) } f.UI.Nodes.Upsert(node.NewInputField("code", "", node.CodeGroup, node.InputAttributeTypeText)) + ds, err := s.deps.Config().DefaultIdentityTraitsSchemaURL(r.Context()) + if err != nil { + return s.handleRegistrationError(w, r, f, &p, err) + } + if err := registration.SortNodes(r.Context(), f.UI.Nodes, ds.String()); err != nil { + return s.handleRegistrationError(w, r, f, &p, err) + } return s.handleRegistrationError(w, r, f, &p, NewCodeSentError()) } else { code, err := s.deps.CodeAuthenticationService().VerifyCode(r.Context(), f, p.Code)