Base solution for your next web application
Open Closed

Detail message in controller authorization #4027


User avatar
0
mamak created

If user hasn't permission for any Service Method, error msg is ok, is about permission. ("Required permissions were not met...") But for Controller method (returns PartialView) error msg is "an internal error occured..". Not about permission.

I want Controller to show error msg about permission as Service. what can I do?


7 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    You can add this attribute to your methods: [WrapResult(WrapOnSuccess = false, WrapOnError = true)]

  • User Avatar
    0
    mamak created

    Nothing changed. I still get that general message. "an internal error occured during your request"

  • User Avatar
    0
    aaron created
    Support Team

    Can you check the error log in *.Web.Mvc\App_Data\Logs?

  • User Avatar
    0
    mamak created

    It is ok : "Abp.Authorization.AbpAuthorizationException: Required permissions are not granted. At least one of these permissions must be granted: *** "

    But message shown on alert is like "an internal error occured during your request"

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mamak,

    How do you call your controller action ? Via an ajax request ?

  • User Avatar
    0
    mamak created

    Controller: HastaTakip, Action: MuayeneModal

    var _muayeneModal = new app.ModalManager({ modalId: "modalMuayene", viewUrl: abp.appPath + 'Mpa/HastaTakip/MuayeneModal',
    modalClass: 'MuayeneModal', modalData: hastaId }); _muayeneModal.open();

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mamak,

    I have checked and ABP does not wrap response for partialview results. So, you need to hide the item which opens modal if user does not have required permisison.