From 1683c0d62e4803a0163d16fc9820a10d5d8d1e46 Mon Sep 17 00:00:00 2001 From: "Merlin (megu)" Date: Thu, 21 Apr 2022 09:50:01 +0000 Subject: [PATCH] [FIX] web_editor: remove command /image for portal users The command `/image` used by portal users (in a forum post for example) throws an access error. This fix removes this command for portal users until master. In master, the command is reintroduced [here]. Indeed, before the new editor in v15, those restricted users could insert an image as we were using an "in place" image upload dialog from summernote resulting in simple base64 image added in the image tag. This allowed to add image without creating an attachment. But with the new editor, there is no such base64 image upload, and it would be too tedious / risky to introduce one in stable. [here]: https://github.com/odoo/odoo/pull/82612 opw-2648770 task-2811325 X-original-commit: e453d4c119a69f285d9a014babe485492bbe9c40 Part-of: odoo/odoo#89890 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 15baa854664..4022348ceb0 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -3,6 +3,7 @@ odoo.define('web_editor.wysiwyg', function (require) { const dom = require('web.dom'); const core = require('web.core'); +const session = require('web.session'); const Widget = require('web.Widget'); const Dialog = require('web.Dialog'); const customColors = require('web_editor.custom_colors'); @@ -98,6 +99,7 @@ const Wysiwyg = Widget.extend({ var options = this._editorOptions(); this._value = options.value; + this.options.isInternalUser = await session.user_has_group('base.group_user'); this.$editable = this.$editable || this.$el; this.$editable.html(this._value); @@ -1793,7 +1795,9 @@ const Wysiwyg = Widget.extend({ }, 150); }, }, - { + ]; + if (options.isInternalUser) { + commands.push({ groupName: 'Medias', title: 'Image', description: 'Insert an image.', @@ -1801,8 +1805,8 @@ const Wysiwyg = Widget.extend({ callback: () => { this.openMediaDialog(); }, - }, - ]; + }); + } if (options.allowCommandVideo) { commands.push({ groupName: 'Medias',