define access control with editor in .net core

define access control with editor in .net core

Pedro MartinsPedro Martins Posts: 22Questions: 11Answers: 0
edited October 2019 in Free community support

Hello i started using Editor and i can´t seem to find any example on how to define view and edit privileges for a table...
Can anybody give me some help!?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Pedro Martins ,

    This section of the manual should help - it's addressing this very aspect.

    Cheers,

    Colin

  • Pedro MartinsPedro Martins Posts: 22Questions: 11Answers: 0

    Hello @colin i don´t know how to use the access.editing code.
    I usually define in my controllers access this way...

    [Authorize(Roles = "Editor")]
    public IActionResult Add()

    Or in my view to show or hide stuff
    if(User.IsInRole("Editor")

    Do you have any example of it???

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    We don't make any assumptions about the login / security framework you are using, so as Colin says, you need to setup your Editor instance with the permissions that you want through the Field.Set() / Field.Get() methods - e.g.:

    // Default - disallow editing
    editor.Field("myField").Set(false);
    
    if(User.IsInRole("Editor") {
      editor.Field("myField").Set(true);
    }
    

    Allan

  • Pedro MartinsPedro Martins Posts: 22Questions: 11Answers: 0

    Thanks Alan that should work fine. Will give you feedback as soon as i test it

This discussion has been closed.