From 668f6b246db1f61b9800f7581bedba4fa25318c4 Mon Sep 17 00:00:00 2001 From: hackerman <3372410+aeneasr@users.noreply.github.com> Date: Mon, 21 Feb 2022 13:39:34 +0100 Subject: [PATCH] fix: appropriately pass context around (#2241) Closes https://github.com/ory/cloud/issues/56 --- cmd/hashers/argon2/root.go | 2 +- selfservice/flow/settings/error.go | 2 +- selfservice/flow/settings/handler.go | 2 +- selfservice/flow/settings/sort.go | 4 +--- selfservice/flow/settings/strategy_helper_test.go | 6 ++++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/hashers/argon2/root.go b/cmd/hashers/argon2/root.go index ad8fa1dc68d7..fa122951f666 100644 --- a/cmd/hashers/argon2/root.go +++ b/cmd/hashers/argon2/root.go @@ -64,7 +64,7 @@ func configProvider(cmd *cobra.Command, flagConf *argon2Config) (*argon2Config, conf := &argon2Config{} var err error conf.config, err = config.New( - context.Background(), + cmd.Context(), l, cmd.ErrOrStderr(), configx.WithFlags(cmd.Flags()), diff --git a/selfservice/flow/settings/error.go b/selfservice/flow/settings/error.go index 5d2e77d57386..086f7611f05e 100644 --- a/selfservice/flow/settings/error.go +++ b/selfservice/flow/settings/error.go @@ -206,7 +206,7 @@ func (s *ErrorHandler) WriteFlowError( return } - if err := sortNodes(f.UI.Nodes, schema.RawURL); err != nil { + if err := sortNodes(r.Context(), f.UI.Nodes, schema.RawURL); err != nil { s.forward(w, r, f, err) return } diff --git a/selfservice/flow/settings/handler.go b/selfservice/flow/settings/handler.go index f347a9449441..310c81688c29 100644 --- a/selfservice/flow/settings/handler.go +++ b/selfservice/flow/settings/handler.go @@ -126,7 +126,7 @@ func (h *Handler) NewFlow(w http.ResponseWriter, r *http.Request, i *identity.Id return nil, err } - if err := sortNodes(f.UI.Nodes, ds.String()); err != nil { + if err := sortNodes(r.Context(), f.UI.Nodes, ds.String()); err != nil { return nil, err } diff --git a/selfservice/flow/settings/sort.go b/selfservice/flow/settings/sort.go index 9dabb7889fca..93c2d9082107 100644 --- a/selfservice/flow/settings/sort.go +++ b/selfservice/flow/settings/sort.go @@ -6,9 +6,7 @@ import ( "github.com/ory/kratos/ui/node" ) -var ctx = context.Background() - -func sortNodes(n node.Nodes, schemaRef string) error { +func sortNodes(ctx context.Context, n node.Nodes, schemaRef string) error { return n.SortBySchema(ctx, node.SortBySchema(schemaRef), node.SortByGroups([]node.Group{ diff --git a/selfservice/flow/settings/strategy_helper_test.go b/selfservice/flow/settings/strategy_helper_test.go index 5fd8fac32c5c..9bd1ab759744 100644 --- a/selfservice/flow/settings/strategy_helper_test.go +++ b/selfservice/flow/settings/strategy_helper_test.go @@ -1,10 +1,12 @@ package settings import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/ory/kratos/identity" "github.com/ory/kratos/x" - "github.com/stretchr/testify/require" - "testing" ) func TestGetIdentityToUpdate(t *testing.T) {