Commit 117e5199 authored by Eric's avatar Eric

modify ValidateUserAssetPermission

parent cccf0ae5
module cocogo module cocogo
require ( require (
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/gliderlabs/ssh v0.1.4 // indirect
github.com/ibuler/ssh v0.1.5 github.com/ibuler/ssh v0.1.5
github.com/jarcoal/httpmock v1.0.3 github.com/jarcoal/httpmock v1.0.3
github.com/konsorten/go-windows-terminal-sequences v1.0.2 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/fs v0.1.0 github.com/kr/fs v0.1.0 // indirect
github.com/kr/pty v1.1.4 github.com/kr/pty v1.1.4
github.com/mattn/go-runewidth v0.0.4 github.com/leonelquinteros/gotext v1.4.0
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.1 github.com/olekukonko/tablewriter v0.0.1
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1 // indirect
github.com/pkg/sftp v1.10.0 github.com/pkg/sftp v1.10.0
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.1 github.com/sirupsen/logrus v1.4.1
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca
golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734
golang.org/x/sys v0.0.0-20190425145619-16072639606e
gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 v2.2.2
) )
...@@ -33,19 +33,23 @@ func GetUserNodes(userId, cachePolicy string) (nodes model.NodeList) { ...@@ -33,19 +33,23 @@ func GetUserNodes(userId, cachePolicy string) (nodes model.NodeList) {
return return
} }
func ValidateUserAssetPermission(userId, assetId, systemUserId string) bool { func ValidateUserAssetPermission(userId, assetId, systemUserId, action string) bool {
params := map[string]string{ params := map[string]string{
"user_id": userId, "user_id": userId,
"asset_id": assetId, "asset_id": assetId,
"system_user_id": systemUserId, "system_user_id": systemUserId,
"cache_policy": "1", "action_name": action,
} }
Url := authClient.ParseUrlQuery(ValidateUserAssetPermissionURL, params) Url := authClient.ParseUrlQuery(ValidateUserAssetPermissionURL, params)
err := authClient.Get(Url, nil) var res struct {
Msg bool `json:"msg"`
}
err := authClient.Get(Url, &res)
if err != nil { if err != nil {
logger.Error(err) logger.Error(err)
return false return false
} }
return true return res.Msg
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment