Skip to content
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

feat: one-time code native flows #3516

Merged
merged 11 commits into from
Oct 2, 2023
23 changes: 19 additions & 4 deletions selfservice/strategy/code/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ func (s *Strategy) PopulateMethod(r *http.Request, f flow.Flow) error {
} else if f.GetFlowName() == flow.LoginFlow {
// we use the identifier label here since we don't know what
// type of field the identifier is
nodes.Upsert(
node.NewInputField("identifier", nil, node.DefaultGroup, node.InputAttributeTypeText, node.WithRequiredInputAttribute).
WithMetaLabel(text.NewInfoNodeLabelID()),
)
nodes.Upsert(node.NewInputField("identifier", "", node.DefaultGroup, node.InputAttributeTypeText, node.WithRequiredInputAttribute).WithMetaLabel(text.NewInfoNodeLabelID()))
} else if f.GetFlowName() == flow.RegistrationFlow {
ds, err := s.deps.Config().DefaultIdentityTraitsSchemaURL(r.Context())
if err != nil {
Expand Down Expand Up @@ -221,6 +218,15 @@ func (s *Strategy) PopulateMethod(r *http.Request, f flow.Flow) error {
// so we can retry the code flow with the same data
for _, n := range f.GetUI().Nodes {
if n.Group == node.DefaultGroup {
// we don't need the user to change the values here
// for better UX let's make them disabled
// when there are errors we won't hide the fields
if len(n.Messages) == 0 {
if input, ok := n.Attributes.(*node.InputAttributes); ok {
input.Type = "hidden"
n.Attributes = input
}
}
freshNodes = append(freshNodes, n)
}
}
Expand All @@ -241,6 +247,15 @@ func (s *Strategy) PopulateMethod(r *http.Request, f flow.Flow) error {
}

if n.Group == node.DefaultGroup {
// we don't need the user to change the values here
// for better UX let's make them disabled
// when there are errors we won't hide the fields
if len(n.Messages) == 0 {
if input, ok := n.Attributes.(*node.InputAttributes); ok {
input.Type = "hidden"
n.Attributes = input
}
}
freshNodes = append(freshNodes, n)
}
}
Expand Down
Loading
Loading