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: change method=profile:back to screen=previous #4119

Merged
merged 7 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ require (
github.com/ory/jsonschema/v3 v3.0.8
github.com/ory/mail/v3 v3.0.0
github.com/ory/nosurf v1.2.7
github.com/ory/x v0.0.655
github.com/ory/x v0.0.656-0.20240924084701-ce6822d48829
github.com/peterhellberg/link v1.2.0
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ github.com/ory/pop/v6 v6.2.0 h1:hRFOGAOEHw91kUHQ32k5NHqCkcHrRou/romvrJP1w0E=
github.com/ory/pop/v6 v6.2.0/go.mod h1:okVAYKGtgunD/wbW3NGhZTndJCS+6FqO+cA89rQ4doc=
github.com/ory/sessions v1.2.2-0.20220110165800-b09c17334dc2 h1:zm6sDvHy/U9XrGpixwHiuAwpp0Ock6khSVHkrv6lQQU=
github.com/ory/sessions v1.2.2-0.20220110165800-b09c17334dc2/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/ory/x v0.0.655 h1:P+uwq8GE2YoB9sEyo/8nxuPwdHzBvXE/Xnkyujl7HeQ=
github.com/ory/x v0.0.655/go.mod h1:M+0EAXo7DT7Z2/Yrzvh4mgxOoV1fGI1jOKyAJ72d4Qs=
github.com/ory/x v0.0.656-0.20240924084701-ce6822d48829 h1:y9BraWW+kjp/yYeuRLKBu951WVaLe2Z7lTqb4mPMlFk=
github.com/ory/x v0.0.656-0.20240924084701-ce6822d48829/go.mod h1:M+0EAXo7DT7Z2/Yrzvh4mgxOoV1fGI1jOKyAJ72d4Qs=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"screen": {
"type": "string",
"enum": [
"credential-selection"
"credential-selection",
"previous"
]
},
"method": {
Expand Down
3 changes: 3 additions & 0 deletions selfservice/strategy/profile/.schema/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"csrf_token": {
"type": "string"
},
"action": {
"type": "string"
},
"transient_payload": {
"type": "object",
"additionalProperties": true
Expand Down
31 changes: 21 additions & 10 deletions selfservice/strategy/profile/two_step_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"encoding/json"
"net/http"

"github.com/ory/x/otelx/semconv"

"go.opentelemetry.io/otel/attribute"

"github.com/ory/x/otelx"
Expand Down Expand Up @@ -65,6 +67,15 @@ func (s *Strategy) PopulateRegistrationMethod(r *http.Request, f *registration.F
return nil
}

// The RegistrationScreen
// swagger:enum RegistrationScreen
type RegistrationScreen string

const (
RegistrationScreenCredentialSelection RegistrationScreen = "credential-selection"
RegistrationScreenPrevious RegistrationScreen = "previous"
)

// Update Registration Flow with Profile Method
//
// swagger:model updateRegistrationFlowWithProfileMethod
Expand Down Expand Up @@ -92,7 +103,7 @@ type updateRegistrationFlowWithProfileMethod struct {
// selection screen.
//
// required: false
Screen string `json:"screen" form:"screen"`
Screen RegistrationScreen `json:"screen" form:"screen"`

// FlowIDRequestID is the flow ID.
//
Expand Down Expand Up @@ -129,16 +140,16 @@ func (s *Strategy) Register(w http.ResponseWriter, r *http.Request, regFlow *reg
return s.handleRegistrationError(r, regFlow, params, err)
}

if params.Screen == "credential-selection" {
params.Method = "profile"
}

switch params.Method {
case "profile":
if params.Method == "profile" || params.Screen == RegistrationScreenCredentialSelection {
return s.displayStepTwoNodes(ctx, w, r, regFlow, i, params)
case "profile:back":
} else if params.Method == "profile:back" {
// "profile:back" is kept for backwards compatibility.
span.AddEvent(semconv.NewDeprecatedFeatureUsedEvent(ctx, "profile:back"))
return s.displayStepOneNodes(ctx, w, r, regFlow, params)
} else if params.Screen == RegistrationScreenPrevious {
return s.displayStepOneNodes(ctx, w, r, regFlow, params)
}

// Default case
span.SetAttributes(attribute.String("not_responsible_reason", "method mismatch"))
return flow.ErrStrategyNotResponsible
Expand Down Expand Up @@ -194,8 +205,8 @@ func (s *Strategy) displayStepTwoNodes(ctx context.Context, w http.ResponseWrite
regFlow.UI.Messages.Add(text.NewInfoSelfServiceChooseCredentials())

regFlow.UI.Nodes.Append(node.NewInputField(
"method",
"profile:back",
"action",
"back",
aeneasr marked this conversation as resolved.
Show resolved Hide resolved
node.ProfileGroup,
node.InputAttributeTypeSubmit,
).WithMetaLabel(text.NewInfoRegistrationBack()))
Expand Down
9 changes: 7 additions & 2 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -3244,8 +3244,13 @@
"type": "string"
},
"screen": {
"description": "Screen requests navigation to a previous screen.\n\nThis must be set to credential-selection to go back to the credential\nselection screen.",
"type": "string"
"description": "Screen requests navigation to a previous screen.\n\nThis must be set to credential-selection to go back to the credential\nselection screen.\ncredential-selection RegistrationScreenCredentialSelection\nprevious RegistrationScreenPrevious",
"enum": [
"credential-selection",
"previous"
],
"type": "string",
"x-go-enum-desc": "credential-selection RegistrationScreenCredentialSelection\nprevious RegistrationScreenPrevious"
},
"traits": {
"description": "Traits\n\nThe identity's traits.",
Expand Down
9 changes: 7 additions & 2 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6228,8 +6228,13 @@
"type": "string"
},
"screen": {
"description": "Screen requests navigation to a previous screen.\n\nThis must be set to credential-selection to go back to the credential\nselection screen.",
"type": "string"
"description": "Screen requests navigation to a previous screen.\n\nThis must be set to credential-selection to go back to the credential\nselection screen.\ncredential-selection RegistrationScreenCredentialSelection\nprevious RegistrationScreenPrevious",
"type": "string",
"enum": [
"credential-selection",
"previous"
],
"x-go-enum-desc": "credential-selection RegistrationScreenCredentialSelection\nprevious RegistrationScreenPrevious"
},
"traits": {
"description": "Traits\n\nThe identity's traits.",
Expand Down
Loading