From c5654846d3b8b002284dee57aa50e95d67649f0e Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 24 十月 2023 18:59:31 +0800
Subject: [PATCH] 集群退出密码

---
 system-service/controllers/cluster.go |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/system-service/controllers/cluster.go b/system-service/controllers/cluster.go
index 39b980f..90c5ee3 100644
--- a/system-service/controllers/cluster.go
+++ b/system-service/controllers/cluster.go
@@ -75,10 +75,10 @@
 			return &bhomeclient.Reply{Success: true, Data: map[string]interface{}{
 				"clusterId":   arr[0].ClusterId,
 				"clusterName": arr[0].ClusterName,
-				"password":    arr[0].Password,
-				"nodes":       nodes,
-				"virtualIp":   arr[0].VirtualIp,
-				"localId":     config.Server.AnalyServerId,
+				//"password":    arr[0].Password,
+				"nodes":     nodes,
+				"virtualIp": arr[0].VirtualIp,
+				"localId":   config.Server.AnalyServerId,
 			}}
 		} else {
 			return &bhomeclient.Reply{Success: true}
@@ -251,7 +251,8 @@
 }
 
 type LeaveArg struct {
-	IsDel bool `json:"isDel"` //鏄惁鍒犻櫎鏁版嵁
+	IsDel bool   `json:"isDel"`    //鏄惁鍒犻櫎鏁版嵁
+	Pwd   string `json:"password"` //鏄惁鍒犻櫎鏁版嵁
 }
 
 // @Summary 閫�鍑洪泦缇�
@@ -264,6 +265,21 @@
 func (cc ClusterController) Leave(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply {
 	var reqBody LeaveArg
 	c.BindJSON(&reqBody)
+
+	var clusterE models.Cluster
+	arr, err := clusterE.FindAll()
+	if err != nil {
+		return &bhomeclient.Reply{Success: false, Msg: "闆嗙兢鏌ヨ澶辫触"}
+	}
+
+	if arr != nil && len(arr) > 0 {
+		if config.ClusterSet.PwdPre+reqBody.Pwd != arr[0].Password {
+			return &bhomeclient.Reply{Success: false, Msg: "瀵嗙爜閿欒"}
+		}
+	} else {
+		return &bhomeclient.Reply{Success: false, Msg: "闆嗙兢鏌ヨ澶辫触"}
+	}
+
 	sv := service.NewClusterService(h.Bk)
 	if b, err := sv.Leave(reqBody.IsDel); b {
 		return &bhomeclient.Reply{Success: true, Msg: "閫�鍑烘垚鍔�"}

--
Gitblit v1.8.0