Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jan 24, 2018 @ 15:32
    Matthew Wise
    0

    Angular dataTypeResource getByName causes a 401 unathorized.

    Hi Guys,

    I have a field type in Umbraco Forms that calls for data type in order to get it's configuration, in this case, an RTE however unless the user has Developer section access the call causes a 401 Unauthorized.

    https://our.umbraco.org/apidocs/ui/#/api/umbraco.resources.dataTypeResource

    The call I make to get the data type:

    dataTypeResource.getByName("Form RTE").then(function (d) {
            $scope.htmfield = [{
                alias: "htmfield",
                label: "Html",
                view: "rte",
                config: {
                    editor: d.preValues[0].value
                },
                value: $scope.setting.value
            }];
    });
    

    Thanks

    Matt

  • Cristhian Amaya 52 posts 423 karma points
    Jan 25, 2018 @ 07:17
    Cristhian Amaya
    100

    Hi Matthew,

    I'm afraid you will have to look for an alternative to accomplish what you need. The data type API is not supposed to be used outside of the backoffice. From the Umbraco source:

    The security for this controller is defined to allow full CRUD access to data types if the user has access to either: Content Types, Member Types or Media Types ... and of course to Data Types

    You can check that at: https://github.com/umbraco/Umbraco-CMS/blob/e0025db56d52b770d2b3aedbd48a3b804fd15ef0/src/Umbraco.Web/Editors/DataTypeController.cs#L31

    Cheers!

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jan 25, 2018 @ 08:14
    Matthew Wise
    0

    Hi Cristhian,

    Thanks for the link, I ended up doing just that custom API controller,

    and a copy paste of the action I needed :)

    Matt

  • Q-ten 16 posts 116 karma points
    Jan 26, 2018 @ 13:35
    Q-ten
    0

    Hi Matthew,

    Just realised I have the same problem as you:

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/90252-disabling-backoffice-section-disables-api-access-to-users#comment-285008

    Looks like I'm going to have to just re-implement those calls into my own API controller like you.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies