When an user is not authorized to see certain data/layers in webmap because he is not a member of a group, the error appears

But is there a way to auto hide layers in a webmap when an user is opening a viewer?
Use case:
I have created one GIS viewer, added the necessary data to this GIS viewer. Different stakeholders have access to this GIS viewer and it depends on their role which information they can access. Stakeholders are assigned to different groups, as well the GIS data they have access too.
One GIS viewer is much easier to maintain than multiple GIS viewers per stakeholder. If layers are auto hide related to the logged in user it will looks more professional then the error message.