Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • claudiobosticco
    replied
    Thank you very much for the clarification, I will update my code accordingly.
    Perhaps it would be better to also update the declarativeSecurity example, which I took inspiration from:
    Code:
    dynamicProperties: {
                        canEdit: { operator: "or",
                                  criteria: [
                                      { fieldName: "auth.roles", operator:"contains", value:"CEO" },
                                      { fieldName: "auth.roles", operator:"contains", value:"HR" }
                                  ]
                                 }
                    }

    Leave a comment:


  • Isomorphic
    replied
    This behavior is correct. "auth.roles" is a multiple:true field so the specified operator is evaluated against each value in the list. If any match, the criteria is true.

    The correct operator in this use-case is "equals" to match "CE" exactly in the auth.roles list.

    Leave a comment:


  • claudiobosticco
    replied
    Hi, can I ask if you can see the problem now?

    Leave a comment:


  • claudiobosticco
    replied
    yes, actually
    Code:
    isc.Authentication.setRoles(value);
    it's the first line in the changed method:

    Code:
                        changed: function (form, item, value) {
                            isc.Authentication.setRoles(value);
                            mainLayout.addMember(isc.IButton.create({
                                ID: "testButton",
                                width: 200,
                                enableWhen: {fieldName: "auth.roles", operator: "contains", value: "CE"}
                            }));
                            testButton.setTitle(value)
                        }

    Leave a comment:


  • Isomorphic
    replied
    Well, you are referring to auth.roles, but that doesn't seem to be set up. Presumably there is a call to Authentication.setRoles() somewhere?

    https://smartclient.com/smartclient-...ation.setRoles

    Leave a comment:


  • claudiobosticco
    replied
    For the test case, I didn’t think it was necessary - I based it on the declarativeSecurity example from the showcase, which also included:
    Code:
    isc.Authentication.setCurrentUser({userId: "jean"});
    but it doesn’t seem to change the result.

    Or do you mean you’d like to see my actual application code?

    Leave a comment:


  • Isomorphic
    replied
    Presumably you are also setting up the user data? Can you show that code?

    Leave a comment:


  • claudiobosticco
    started a topic Role matching issue with rule context

    Role matching issue with rule context

    SmartClient Version: v13.1p_2025-08-08/AllModules Development Only (built 2025-08-08)

    Hi, I think I’ve found an issue with using client-side Authentication in combination with the rule context. If you try this test case:

    Code:
    isc.HLayout.create({
        ID: "mainLayout",
        membersMargin: 15,
        members: [
            isc.DynamicForm.create({
                ID: "formRoles",
                fields: [
                    {
                        name: "selectRoles", title: "Roles",
                        editorType: "SelectItem",
                        multiple: true,
                        valueMap: {
                            "CE": "CE",
                            "CEO": "CEO"
                        },
                        changed: function (form, item, value) {
                            isc.Authentication.setRoles(value);
                            mainLayout.addMember(isc.IButton.create({
                                ID: "testButton",
                                width: 200,
                                enableWhen: {fieldName: "auth.roles", operator: "contains", value: "CE"}
                            }));
                            testButton.setTitle(value)
                        }
                    }]
            })
        ]
    });
    you’ll see that the button gets enabled both when selecting "CE" from the select (which is the role actually required in the enableWhen) and also when selecting only the "CEO" role.
    It seems like it's matching based on a substring rather than checking for the actual presence of the string in the array.
Working...
X