diff --git a/selfservice/form/html_form.go b/selfservice/form/html_form.go
index f4f749f41f2..43ff31ea563 100644
--- a/selfservice/form/html_form.go
+++ b/selfservice/form/html_form.go
@@ -285,7 +285,6 @@ func (c *HTMLForm) SetValue(name string, value interface{}) {
if f := c.getField(name); f != nil {
f.Value = value
- f.Type = toFormType(name, value)
return
}
c.Fields = append(c.Fields, Field{
diff --git a/selfservice/strategy/password/registration.go b/selfservice/strategy/password/registration.go
index da0626fe8de..d2080e57736 100644
--- a/selfservice/strategy/password/registration.go
+++ b/selfservice/strategy/password/registration.go
@@ -58,7 +58,8 @@ func (s *Strategy) handleRegistrationError(w http.ResponseWriter, r *http.Reques
if p != nil {
for _, field := range form.NewHTMLFormFromJSON("", p.Traits, "traits").Fields {
- method.Config.SetField(field)
+ // we only set the value and not the whole field because we want to keep types from the initial form generation
+ method.Config.SetValue(field.Name, field.Value)
}
}
diff --git a/selfservice/strategy/password/registration_test.go b/selfservice/strategy/password/registration_test.go
index e783cee6c26..d3e0098ceb1 100644
--- a/selfservice/strategy/password/registration_test.go
+++ b/selfservice/strategy/password/registration_test.go
@@ -104,6 +104,9 @@ func TestRegistration(t *testing.T) {
})
t.Run("case=should show the error ui because the request payload is malformed", func(t *testing.T) {
+ viper.Set(configuration.ViperKeyDefaultIdentitySchemaURL, "file://./stub/profile.schema.json")
+ defer viper.Set(configuration.ViperKeyDefaultIdentitySchemaURL, "file://./stub/registration.schema.json")
+
t.Run("type=api", func(t *testing.T) {
f := testhelpers.InitializeRegistrationFlowViaAPI(t, apiClient, publicTS)
c := testhelpers.GetRegistrationFlowMethodConfig(t, f.Payload, identity.CredentialsTypePassword.String())
@@ -121,6 +124,7 @@ func TestRegistration(t *testing.T) {
assert.Contains(t, res.Request.URL.String(), uiTS.URL+"/registration-ts")
assert.NotEmpty(t, gjson.Get(body, "id").String(), "%s", body)
assert.Contains(t, gjson.Get(body, "methods.password.config.messages.0.text").String(), "invalid URL escape", "%s", body)
+ assert.Equal(t, "email", gjson.Get(body, "methods.password.config.fields.#(name==\"traits.email\").type").String(), "%s", body)
})
})
diff --git a/selfservice/strategy/password/stub/profile.schema.json b/selfservice/strategy/password/stub/profile.schema.json
index f3c1a22b1fd..7a7d716c4d8 100644
--- a/selfservice/strategy/password/stub/profile.schema.json
+++ b/selfservice/strategy/password/stub/profile.schema.json
@@ -7,18 +7,19 @@
"traits": {
"type": "object",
"properties": {
- "email": {
- "type": "string",
- "ory.sh/kratos": {
- "credentials": {
- "password": {
- "identifier": true
+ "email": {
+ "type": "string",
+ "format": "email",
+ "ory.sh/kratos": {
+ "credentials": {
+ "password": {
+ "identifier": true
+ }
+ }
}
}
}
}
- }
- }
},
"additionalProperties": false
}