MCPcopy Create free account
hub / github.com/actiontech/dtle / checkUserAccess

Function checkUserAccess

api/handler/v2/user.go:391–402  ·  view source on GitHub ↗
(logger g.LoggerType, c echo.Context, operationUser string)

Source from the content-addressed store, hash-verified

389}
390
391func checkUserAccess(logger g.LoggerType, c echo.Context, operationUser string) (bool, error) {
392 storeManager, err := common.NewStoreManager([]string{handler.ConsulAddr}, logger)
393 if err != nil {
394 return false, fmt.Errorf("consul_addr=%v; connect to consul failed: %v", handler.ConsulAddr, err)
395 }
396 currentUser, err := getCurrentUser(c)
397 if err != nil {
398 return false, err
399 }
400 access := userHasAccess(storeManager, operationUser, currentUser)
401 return access, nil
402}
403
404func userHasAccess(storeManager *common.StoreManager, operationUser string, currentUser *common.User) bool {
405 // get current role

Callers 4

CreateUserV2Function · 0.85
UpdateUserV2Function · 0.85
ResetPasswordV2Function · 0.85
DeleteUserV2Function · 0.85

Calls 3

NewStoreManagerFunction · 0.92
getCurrentUserFunction · 0.85
userHasAccessFunction · 0.85

Tested by

no test coverage detected