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 all 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ docs/swagger:
npx @redocly/openapi-cli preview-docs spec/swagger.json

.bin/golangci-lint: Makefile
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -d -b .bin v1.59.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -d -b .bin v1.61.0

.bin/hydra: Makefile
bash <(curl https://raw.githubusercontent.com/ory/meta/master/install.sh) -d -b .bin hydra v2.2.0-rc.3
Expand All @@ -60,7 +60,7 @@ docs/swagger:
.bin/buf: Makefile
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v1.39.0/buf-$(shell uname -s)-$(shell uname -m).tar.gz" | \
tar -xvzf - -C ".bin/" --strip-components=2 buf/bin/buf buf/bin/protoc-gen-buf-breaking buf/bin/protoc-gen-buf-lint
tar -xvzf - -C ".bin/" --strip-components=2 buf/bin/buf buf/bin/protoc-gen-buf-breaking buf/bin/protoc-gen-buf-lint
touch -a -m .bin/buf

.PHONY: lint
Expand Down
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
32 changes: 22 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 @@
"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,16 @@
return nil
}

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

const (
//nolint:gosec // not a credential
RegistrationScreenCredentialSelection RegistrationScreen = "credential-selection"
RegistrationScreenPrevious RegistrationScreen = "previous"
)

// Update Registration Flow with Profile Method
//
// swagger:model updateRegistrationFlowWithProfileMethod
Expand Down Expand Up @@ -92,7 +104,7 @@
// 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 +141,16 @@
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 {

Check warning on line 144 in selfservice/strategy/profile/two_step_registration.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/profile/two_step_registration.go#L144

Added line #L144 was not covered by tests
return s.displayStepTwoNodes(ctx, w, r, regFlow, i, params)
case "profile:back":
} else if params.Method == "profile:back" {

Check warning on line 146 in selfservice/strategy/profile/two_step_registration.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/profile/two_step_registration.go#L146

Added line #L146 was not covered by tests
// "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 {

Check warning on line 150 in selfservice/strategy/profile/two_step_registration.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/profile/two_step_registration.go#L148-L150

Added lines #L148 - L150 were not covered by tests
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 +206,8 @@
regFlow.UI.Messages.Add(text.NewInfoSelfServiceChooseCredentials())

regFlow.UI.Nodes.Append(node.NewInputField(
"method",
"profile:back",
"screen",
"previous",

Check warning on line 210 in selfservice/strategy/profile/two_step_registration.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/profile/two_step_registration.go#L209-L210

Added lines #L209 - L210 were not covered by tests
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ context("Registration success with two-step signup", () => {
cy.get('[name="method"][value="profile"]').click()

// navigate back, fill traits again
cy.get('[name="method"][value="profile:back"]').click()
cy.get('[name="screen"][value="previous"]').click()
cy.get('input[name="traits.email"]').type(
"{selectall}{backspace}" + email,
)
Expand Down
Loading