Bläddra i källkod

Fixed issue on unable to edit group that its name contain space

TC pushbot 5 4 år sedan
förälder
incheckning
259f614065

+ 19 - 0
hardware.power.go

@@ -57,6 +57,9 @@ func hardware_power_poweroff(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	log.Println("Shutting Down")
+	return
+
 	if runtime.GOOS == "windows" {
 		//Only allow Linux to do power operation
 		cmd := exec.Command("shutdown", "-s", "-t", "20")
@@ -111,6 +114,22 @@ func hardware_power_restart(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	//Double check password for this user
+	password, err := mv(r, "pw", true)
+	if err != nil {
+		sendErrorResponse(w, "Password Incorrect")
+		return
+	}
+
+	passwordCorrect := authAgent.ValidateUsernameAndPassword(userinfo.Username, password)
+	if !passwordCorrect {
+		sendErrorResponse(w, "Password Incorrect")
+		return
+	}
+
+	log.Println("Restarting")
+	return
+
 	if runtime.GOOS == "windows" {
 		//Only allow Linux to do power operation
 		cmd := exec.Command("shutdown", "-r", "-t", "20")

+ 0 - 2
mod/disk/diskcapacity/dftool/dftool.go

@@ -2,7 +2,6 @@ package dftool
 
 import (
 	"errors"
-	"log"
 	"os/exec"
 	"path/filepath"
 	"runtime"
@@ -50,7 +49,6 @@ func GetCapacityInfoFromPath(realpath string) (*Capacity, error) {
 		//Assume Linux or Mac
 		//Use command: df -P {abs_path}
 		cmd := exec.Command("df", "-P", rpathAbs)
-		log.Println("df", "-P", rpathAbs)
 		out, err := cmd.CombinedOutput()
 		if err != nil {
 			return nil, err

+ 18 - 10
web/SystemAO/boot/poweroff.html

@@ -51,8 +51,8 @@
                 var apiObject = {
                     api: "/system/power/shutdown",
                     data: {},
-                    title: "Shutdown Host",
-                    desc: "Authentication is required in order to proceed the shutdown process. Make sure you have access to the host hardware before shutdown.",
+                    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"
                 }
@@ -61,10 +61,12 @@
 
                 ao_module_newfw({
                     url: "SystemAO/security/authreq.html#" + apiObject,
-                    width: 380,
-                    height: 200,
+                    width: 480,
+                    height: 300,
                     appicon: "SystemAO/security/img/lock.svg",
-                    title: "Shutdown - Authentication Required"
+                    title: "Shutdown - Authentication Required",
+                    parent: ao_module_windowID,
+                    callback: "handleCallback"
                 });
             }
 
@@ -72,8 +74,8 @@
                 var apiObject = {
                     api: "/system/power/restart",
                     data: {},
-                    title: "Restart Host",
-                    desc: "Authentication is required in order to proceed the restart process",
+                    title: "Password Required",
+                    desc: "for restarting the ArozOS Host",
                     thisuser: true, //This username as default, set to false for entering other user
                     method: "GET"
                 }
@@ -82,12 +84,18 @@
 
                 ao_module_newfw({
                     url: "SystemAO/security/authreq.html#" + apiObject,
-                    width: 380,
-                    height: 200,
+                    width: 480,
+                    height: 300,
                     appicon: "SystemAO/security/img/lock.svg",
-                    title: "Restart - Authentication Required"
+                    title: "Restart - Authentication Required",
+                    parent: ao_module_windowID,
+                    callback: "handleCallback"
                 });
             }
+
+            function handleCallback(data){
+                console.log(data);
+            }
         </script>
     </body>
 </html>

+ 82 - 2
web/SystemAO/security/authreq.html

@@ -9,22 +9,102 @@
     <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
     <script type="text/javascript" src="../../script/ao_module.js"></script>
     <style>
-    
+   
     </style>
 </head>
 <body>
     <div class="ui container">
-       
+        <h3 class="ui header" style="padding-top: 12px;">
+            <img src="img/lock.svg">
+            <div class="content">
+                <span id="title">Authentication Required</span>
+                <div id="desc" class="sub header">in order to proceed this operation</div>
+            </div>
+        </h3>
+        <p>Username</p>
+        <div class="ui small fluid input" style="margin-top: -10px;">
+            <input id="username" type="text" placeholder="">
+        </div>
+        <p>Password</p>
+        <div class="ui fluid input" style="margin-top: -10px;">
+            <input id="password" type="password" placeholder="">
+        </div>
+        <br>
+        <div align="right">
+            <button class="ui green button" onclick="confirm()">OK</button>
+            <button class="ui button" onclick="cancel()">Cancel</button>
+        </div>
+        
     </div>
     
     <script>
+       ao_module_setFixedWindowSize();
        var actionObject = {};
+       var method = "GET";
        if (window.location.hash.length > 1){
             var object = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
             console.log(object);
+
+            if (typeof(object.title) != "undefined"){
+                $("#title").html(object.title);
+            }
+
+            if (typeof(object.desc) != "undefined"){
+                $("#desc").html(object.desc);
+            }
+
+            if (typeof(object.thisuser) != "undefined" && object.thisuser == true){
+                //Load user info from server side
+                $.get("../../system/desktop/user", function(data){
+                    $("#username").val(data.Username);
+                    $("#username").attr("readonly","true");
+                    $("#username").parent().addClass("disabled");
+                });
+            }
+
+            if (typeof(object.method) != "undefined" && object.method != ""){
+                method = object.method;
+            }
+
+            actionObject = object;
        }else{
            //Invalid usage
        }
+
+
+       function confirm(){
+        $("password").parent().removeClass("error");
+            var payload = actionObject.data;
+            //Append custom payload to the original payload
+            payload.username = $("#username").val();
+            payload.password = $("#password").val();
+            //Request endpoint
+            $.ajax({
+                url: "../../" + actionObject.api,
+                data: data,
+                method: method,
+                success: function(data){
+                    if (data.error != undefined){
+                        $("#password").parent().addClass("error");
+                    }else{
+                        if (ao_module_hasParentCallback()){
+                            ao_module_parentCallback(data);
+                        }
+
+                        ao_module_close();
+                    }
+                    
+                }
+            })
+       }
+
+       function cancel(){
+            if (ao_module_hasParentCallback()){
+                ao_module_parentCallback(false);
+            }
+
+            ao_module_close();
+       }
     </script>
 </body>
 </html>

+ 1 - 0
web/SystemAO/users/editgroup.html

@@ -117,6 +117,7 @@
                 window.location.href = "../closeTabInsturction.html";
             }
             var targetUserGroup = window.location.hash.substr(1);
+            targetUserGroup = JSON.parse(decodeURIComponent(targetUserGroup));
             var originalGroupData;
 
             function bytesToSize(bytes) {

+ 2 - 2
web/SystemAO/users/group.html

@@ -117,10 +117,10 @@
 
             function openEditWindow(){
                 ao_module_newfw({
-                    url: "SystemAO/users/editgroup.html#" + currentSelectedGroup,
+                    url: "SystemAO/users/editgroup.html#" + encodeURIComponent(JSON.stringify(currentSelectedGroup)),
                     width: 560,
                     height: 768,
-                    appicon: "SystemAO/users/img/group_white.png",
+                    appicon: "SystemAO/users/img/users-white.svg",
                     title: "Edit User Group",
                     parent: ao_module_windowID,
                     callback: "confirmCreateHandler"

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 27
web/SystemAO/users/img/user - 複製.ai


Vissa filer visades inte eftersom för många filer har ändrats