Cockpit: hide configurations to Users

Continuing from: https://github.com/NethServer/dev/issues/5944

@giacomo What do you think to add this in nethserver packages and show the same error (with a button Back to Dashboard) on all pages? It can complete the work NethServer team is doing on Cockpit.

beforeRouteEnter(to, from, next) {
    next( vm => {
      nethserver.exec(
          ["system-authorization/read"],
          null,
          null,
          function(success) {
            try {
              success = JSON.parse(success);
            } catch (e) {
              console.error(e);
            }
            if (success.applications.indexOf(to.path.substring(1)) == -1) {
              vm.view.isAuth = false; # show error form
            }else{
              vm.view.isAuth = true; # show normal page
            }
          },
          function(error) {
            console.error(error);
          },
          false
        )
    });
  },

Have a nice week! :slight_smile:

1 Like

I can’t tell from the code how the UI will behave.

Could you please describe the implemented behavior? Maybe a screenshot could help here :wink:

IIRC if you are not allowed you are redirected to the dashboard, but except for the terminal, the software center, you should not see the back button. Like giacomo, I am curious of what you would like to implement.

1 Like

I will try to post here a screen asap