From fe22cb57c9d057de8f1d56c3fe922bcedfb104de Mon Sep 17 00:00:00 2001 From: SebClem Date: Mon, 17 Aug 2020 13:05:24 +0200 Subject: [PATCH] :ambulance: Prevent Read Only user to send emergency stop --- .../static/js/simpleemergencystop.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/octoprint_simpleemergencystop/static/js/simpleemergencystop.js b/octoprint_simpleemergencystop/static/js/simpleemergencystop.js index d5c3088..c7e9ff1 100644 --- a/octoprint_simpleemergencystop/static/js/simpleemergencystop.js +++ b/octoprint_simpleemergencystop/static/js/simpleemergencystop.js @@ -43,16 +43,21 @@ $(function () { }; + this.hasControlPermition = function () { + let user = this.loginState.currentUser() + return user.permissions.includes("control") || user.needs.role.includes("control"); + } + this.big_button_visible = function () { - return this.loginState.isUser() && this.settings.big_button(); + return this.loginState.isUser() && this.settings.big_button() && this.hasControlPermition(); }; this.little_button_visible = function () { - return this.loginState.isUser() && !this.settings.big_button(); + return this.loginState.isUser() && !this.settings.big_button() && this.hasControlPermition(); }; this.can_send_command = function () { - return this.loginState.isUser() && this.printerState.isOperational(); + return this.loginState.isUser() && this.hasControlPermition() && this.printerState.isOperational() ; }; this.little_button_css = function () {