Browse Source

Added desktop shutdown password validation

TC pushbot 5 4 years ago
parent
commit
4989e330fb
1 changed files with 35 additions and 27 deletions
  1. 35 27
      web/desktop.system

+ 35 - 27
web/desktop.system

@@ -5350,20 +5350,25 @@
             if (!hardwareman){
                 return
             }
-
-            if (confirm("Confirm Restart?")){
-                $.ajax({
-                    url: "system/power/restart",
-                    success: function(data){
-                        if (data.error !== undefined){
-                            alert(data.error);
-                        }
-                    },
-                    error: function(){
-
-                    }
-                });
+            var apiObject = {
+                api: "/system/power/restart",
+                data: {},
+                title: "Password Required",
+                desc: "for restarting the ArozOS Host",
+                thisuser: true, //This username as default, set to false for entering other user
+                method: "GET"
             }
+
+            apiObject = encodeURIComponent(JSON.stringify(apiObject));
+            newFloatWindow({
+                url: "SystemAO/security/authreq.html#" + apiObject,
+                width: 480,
+                height: 300,
+                appicon: "SystemAO/security/img/lock.svg",
+                title: "Restart - Authentication Required",
+                parent: ao_module_windowID,
+                callback: "handleRestartCallback"
+            });
         }
 
         function shutdown(){
@@ -5371,22 +5376,25 @@
                 return
             }
 
-            if (confirm("Confirm Poweroff?")){
-                $.ajax({
-                    url: "system/power/shutdown",
-                    success: function(data){
-                        if (data.error !== undefined){
-                            alert(data.error);
-                        }else{
-                            //Shutdown suceed
-                        }
-                    },
-                    error: function(){
-                        //Shutdown suceed
-                    }
-                });
+            var apiObject = {
+                api: "/system/power/shutdown",
+                data: {},
+                title: "<i class='red exclamation triangle icon'></i> Shutdown Host <i class='red exclamation triangle icon'></i>",
+                desc: "Please enter your password to confirm operation.",
+                thisuser: true, //This username as default, set to false for entering other user
+                method: "GET"
             }
+            apiObject = encodeURIComponent(JSON.stringify(apiObject));
 
+            newFloatWindow({
+                url: "SystemAO/security/authreq.html#" + apiObject,
+                width: 480,
+                height: 300,
+                appicon: "SystemAO/security/img/lock.svg",
+                title: "Shutdown - Authentication Required",
+                parent: ao_module_windowID,
+                callback: "handleShutdownCallback"
+            })
            
         }