Closed mattearnshaw closed 7 years ago
@gidili can you review this?
@mattearnshaw @tarelli issue: if I understand correctly the change - this might cause tons of exceptions to be raised in the case of non-persisted projects with local storage enabled because the setView call always hits the server, if we don't have the persistence bundle or the project is not persisted we store the view server side in the volatile project object so that when the project is downloaded (download project feature) the views are also serialized(*). The only case the server does not get hit at the moment is if local storage is disabled and there is no persistence (code here).
As I understand it this change is meant to fix the case where the project is persisted BUT the user does not have write access. Is this correct @mattearnshaw and when is it happening? Or are you worried about it happening manually (like from console etc)?
Either way unless I am missing something it might a simple case of adding that check on the client side on this line here adding && GEPPETTO.userController.hasWritePermissions() (we can then remove GEPPETTO.UserController.persistence since the other check includes that).
(*) You might think "this is a bad idea" but we had lengthy conversations at the time and decided that this implementation was better than serailizing the project without views and add them client side tampering on the fly with the json (which was the initial implementation before we decided against it), this way everything gets serialized in one go.
@gidili I added the client side check already here :) I will remove the redundant condition
this fixes issue with OSB sample projects having their experiment state written (since they are persisted, see comodl because osb.org has a temporary fix in place; for example every time you open HH there are more popups because the script runs, and the ones from before have been saved)