Display proper error message when a user doesn't have rights to upload data to dataflow
When a user who doesn't have rights to manage the dataflow specified in the data file (e.g user rights a limited to another agency/space/artefact type etc),
Then in the DLM the error "Whoops. Something went wrong on our side" is displayed.
Instead of returning such error, the user should be properly notified that she/he doesn't have rights to upload data (e.g "You are not authorized to upload data to this dataflow").
Example In details
Trying to upload data to a dataspace (e.g. staging:SIS-CC-reset) where I have limited permissions: 16-CanImportStructures-Can import structures attribute,
The DLM interface returns the above message, and the F12 console returns a 403 Forbidden
.
Solution
HTTP Error 403 Forbidden
When the user permissions are not aligned with the action she/he tries to perform, and the service behind the scene is aware of the 403 Forbidden
state,
then the "upload.unknown"
i18n locale key shouldn't be used in that case (see source file line 173).
Instead, the DLM should return the (new localised) message when the transfer ws returns a 403 error:
EN: "[space] space: The data upload initialisation encountered error(s) and failed.{br}
You are not authorised to import this data. The restriction can be related to the data space, the 'dataflow' type or the dataflow's ID, agency or version for your account or a group account of which you are a member. Contact the data owner or the system administrator to obtain adequate data update permissions."
FR: "Espace [space] : L'initialisation de l'import des données a rencontré une/des erreur(s) et a échoué.{br}
Vous n'êtes pas autorisé à importer ces données. La restriction peut être liée à l'espace de données, au type 'dataflow' ou à l'ID, à l'agence ou à la version du dataflow pour votre compte ou un compte de groupe dont vous êtes membre. Veuillez contacter le propriétaire des données ou l'administrateur système afin d'obtenir les autorisations adéquates de mise à jour des données."
HTTP Error 401 Unauthorized
The DLM should return the (new localised) message when the transfer ws returns a 401 error:
EN: "[space] space: The data upload initialisation encountered error(s) and failed.{br}
You cannot currently import this data because you are not authenticated or your authentication timed out. First login and then try again. If the problem persists, then please contact your system administrator."
FR: "Espace [space] : L'initialisation de l'import des données a rencontré une/des erreur(s) et a échoué.{br}
Vous ne pouvez pas importer ces données car vous n'êtes pas authentifié, ou votre authentification a expiré. Connectez-vous d'abord, puis réessayez. Si le problème persiste, veuillez contacter votre administrateur système."