diff --git a/selfservice/flow/recovery/error.go b/selfservice/flow/recovery/error.go index 975d8e3e0079..1b884dafbe5f 100644 --- a/selfservice/flow/recovery/error.go +++ b/selfservice/flow/recovery/error.go @@ -22,7 +22,7 @@ import ( var ( ErrHookAbortFlow = errors.New("aborted recovery hook execution") - ErrAlreadyLoggedIn = herodot.ErrBadRequest.WithReason("A valid session was detected and thus recovery is not possible.") + ErrAlreadyLoggedIn = herodot.ErrBadRequest.WithID(text.ErrIDAlreadyLoggedIn).WithReason("A valid session was detected and thus recovery is not possible.") ) type ( diff --git a/selfservice/flow/recovery/handler_test.go b/selfservice/flow/recovery/handler_test.go index a2d6091f2bf5..37bf25f2e991 100644 --- a/selfservice/flow/recovery/handler_test.go +++ b/selfservice/flow/recovery/handler_test.go @@ -24,6 +24,7 @@ import ( "github.com/ory/kratos/internal" "github.com/ory/kratos/internal/testhelpers" "github.com/ory/kratos/selfservice/flow/recovery" + "github.com/ory/kratos/text" "github.com/ory/kratos/x" ) @@ -50,6 +51,7 @@ func TestHandlerRedirectOnAuthenticated(t *testing.T) { t.Run("does redirect to default on authenticated request", func(t *testing.T) { body, res := testhelpers.MockMakeAuthenticatedRequest(t, reg, conf, router.Router, x.NewTestHTTPRequest(t, "GET", ts.URL+recovery.RouteInitAPIFlow, nil)) assert.Contains(t, res.Request.URL.String(), recovery.RouteInitAPIFlow) + assert.EqualValues(t, text.ErrIDAlreadyLoggedIn, gjson.GetBytes(body, "error.id").Str) assertx.EqualAsJSON(t, recovery.ErrAlreadyLoggedIn, json.RawMessage(gjson.GetBytes(body, "error").Raw)) }) }