dfoxg / kratos-admin-ui

A simple Admin-Interface for ory/kratos
MIT License
138 stars 28 forks source link

Boolean traits shows as fields, any input leads to mismatch of types sting!=boolean #168

Closed DeamonMV closed 6 months ago

DeamonMV commented 6 months ago

Describe the bug Boolean traits shows as fields, any input leads to mismatch of types sting!=boolean, which lead to problem to update the traits.

To Reproduce Steps to reproduce the behavior:

  1. create a JSON schema
{
  "$id": "https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Person",
  "type": "object",
  "definitions": {
    "tosUrl": {
      "type": "string",
      "const": "http://example.com/terms"
    }
  },
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "title": "E-Mail",
          "minLength": 3,
          "ory.sh/kratos": {
            "credentials": {
              "password": {
                "identifier": true
              }
            },
            "verification": {
              "via": "email"
            },
            "recovery": {
              "via": "email"
            }
          }
        },
        "username": {
          "title": "Username",
          "type": "string",
          "readOnly": true
        },
        "name": {
          "type": "object",
          "properties": {
            "first": {
              "title": "First Name",
              "type": "string"
            },
            "last": {
              "title": "Last Name",
              "type": "string"
            }
          }
        },
        "tos": {
          "title": "Accept Terms of Service",
          "type": "boolean",
          "description": "I accept the terms of service",
          "writeOnly": true,
          "tosUrl": {
            "$ref": "#/definitions/tosUrl"
           }
        },
        "newsletter": {
          "type": "boolean",
          "title": "Newsletter subscription"
        }
      },
      "required": [
        "email",
        "username",
        "tos"
      ],
      "additionalProperties": false
    }
  }
}
  1. register and verify user
  2. open kratos-admin-ui
  3. open created user on edit
  4. update any boolean traits - Accept Terms of Service or Newsletter subscription
  5. See error {"code":400,"status":"Bad Request","reason":"I[#/traits/newsletter] S[#/properties/traits/properties/newsletter/type] expected boolean, but got string","message":"The request was malformed or contained invalid parameters"}

Expected behavior kratos-admin-ui shows checkbox as a checkbox, update of the checkbox passes without errors

Screenshots image

Desktop (please complete the following information):

Additional context

kratos version 1.1.0

kratos-admin-ui used inside docker-compose.yaml as this

  kratos-admin-ui:
    image: ghcr.io/dfoxg/kratos-admin-ui
    ports:
      - 8080:8080
    environment:
      - KRATOS_ADMIN_URL=http://kratos:4434
      - KRATOS_PUBLIC_URL=http://kratos:4433
    depends_on:
      - kratos
      - auth-db
    networks:
      - intranet
dfoxg commented 6 months ago

Thanks for reporting that, i'll have a look at it :)

dfoxg commented 6 months ago

Added with https://github.com/dfoxg/kratos-admin-ui/releases/tag/v2.3.2. Could you test it? :)

DeamonMV commented 6 months ago

@dfoxg Thank you Now it's work fine

image