mjawad096 / laravel-grapesjs

This package provide an esay way to integrate GrapesJS into your laravel proejct.
MIT License
108 stars 54 forks source link

Logging changes and who made them #17

Closed insssomniac closed 2 years ago

insssomniac commented 2 years ago

Hello,

I'm trying to log the changes of the pages, including changes of html made with gjs editor, but it is a problem with the fact that the editor doesn't determine the user who made the changes and saved the page. Is it possible to determine the user, maybe i can pass the current user in the editor view or something like this? (I'm using altek/accountant if it is important)

Thanks for the great product.

ghost commented 2 years ago

Hi @insssomniac, The issue is not clear. Can you please provide the code or any screenshots?

insssomniac commented 2 years ago

Okay, i try to write something like "steps to reproduce" because just code will be not clear also.

  1. Install laravel, create the Page model and implement this jd-dotlogics/laravel-grapesjs module to it. Also it is make sense to add some other basic fields like "name" and "slug" and basic CRUD controller with which we can edit the "name" and "slug", and also we can edit html in the editor.
  2. Install altek/accountant to the project. After this we will have entries in the database as soon as someone changes the page.

Problem is what if someone changing regular fields like "name" or "slug" (post request from the form in "edit" view to the "update" action in controller) -- we have his user id and type, but if this user changes html with the gjs editor -- we don't have any info about who was done it, you can see it on the attached screenshot from the db image

ghost commented 2 years ago

Hi @insssomniac, the issue seems with the package you are using altek/accountant. As there is a mutator for the gjs_data property of your Editable. And it seems your package is not working with the mutators.

insssomniac commented 2 years ago

Hi @jd-dotlogics, it seems problem isn't with a mutator, because if i changing the gjs_data field in the controller and saving the model, my account is detected correctly and shown in log.

It seems what guard "web" doesn't detect the user when saving comes from the editor. Also if I try to get the Auth::user() in the store_gjs_data() function, it returns null. So maybe it is another way to get the user?

ghost commented 2 years ago

Issue resolved, see release # 3.2.1