mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	当证书被API节点或者用户节点使用时不允许删除/规范命名
This commit is contained in:
		@@ -16,7 +16,7 @@ func (this *DeleteAction) RunPost(params struct {
 | 
			
		||||
	// 创建日志
 | 
			
		||||
	defer this.CreateLog(oplogs.LevelInfo, "删除SSL证书 %d", params.CertId)
 | 
			
		||||
 | 
			
		||||
	// 是否正在被使用
 | 
			
		||||
	// 是否正在被服务使用
 | 
			
		||||
	countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{SslCertId: params.CertId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
@@ -26,6 +26,26 @@ func (this *DeleteAction) RunPost(params struct {
 | 
			
		||||
		this.Fail("此证书正在被某些服务引用,请先修改服务后再删除。")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 是否正在被API节点使用
 | 
			
		||||
	countResp, err = this.RPC().APINodeRPC().CountAllEnabledAPINodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledAPINodesWithSSLCertIdRequest{SslCertId: params.CertId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if countResp.Count > 0 {
 | 
			
		||||
		this.Fail("此证书正在被某些API节点引用,请先修改API节点后再删除")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 是否正在被用户节点使用
 | 
			
		||||
	countResp, err = this.RPC().UserNodeRPC().CountAllEnabledUserNodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledUserNodesWithSSLCertIdRequest{SslCertId: params.CertId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if countResp.Count > 0 {
 | 
			
		||||
		this.Fail("此证书正在被某些用户节点引用,请先修改用户节点后再删除")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user