diff --git a/selfservice/strategy/password/.schema/login.schema.json b/selfservice/strategy/password/.schema/login.schema.json index e1f36fbaf3e1..0ceccbc72738 100644 --- a/selfservice/strategy/password/.schema/login.schema.json +++ b/selfservice/strategy/password/.schema/login.schema.json @@ -2,10 +2,6 @@ "$id": "https://schemas.ory.sh/kratos/selfservice/strategy/password/login.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "required": [ - "password", - "method" - ], "properties": { "csrf_token": { "type": "string" @@ -22,25 +18,46 @@ "type": "string" } }, - "if": { - "properties": { - "password_identifier": { - "type": "string", - "minLength": 1 + "allOf": [ + { + "if": { + "properties": { + "method": { + "const": "password" + } + }, + "required": [ + "method" + ] + }, + "then": { + "required": [ + "password" + ] } }, - "required": [ - "password_identifier" - ] - }, - "then": { - "required": [ - "password_identifier" - ] - }, - "else": { - "required": [ - "identifier" - ] - } + { + "if": { + "properties": { + "password_identifier": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "password_identifier" + ] + }, + "then": { + "required": [ + "password_identifier" + ] + }, + "else": { + "required": [ + "identifier" + ] + } + } + ] } diff --git a/selfservice/strategy/password/login_test.go b/selfservice/strategy/password/login_test.go index 9a1de54920f6..f155bba43116 100644 --- a/selfservice/strategy/password/login_test.go +++ b/selfservice/strategy/password/login_test.go @@ -348,6 +348,7 @@ func TestCompleteLogin(t *testing.T) { var values = func(v url.Values) { v.Del("identifier") + v.Set("method", identity.CredentialsTypePassword.String()) v.Set("password", "password") }