// Userは公開鍵をlink_usersから取得して、自身の鍵としてマージする
// Groupはグループのメンバーをlink_groupから取得して、自身のメンバーとしてマージする
509026
func mergeLinkAttribute(master, current linkAttributers, result map[string][]string, nest *int) map[string][]string {
	if current == nil {
		current = master
	}

	if result == nil {
		result = map[string][]string{}
	}

	if nest == nil {
		i := 0
		nest = &i
	}

	for _, v := range current {
		links := v.linkValues()
		if len(links) > 0 {
			ls := master.find(links)
			for _, iv := range ls {
				if len(result[iv.GetName()]) == 0 {
					result[iv.GetName()] = append(result[iv.GetName()], iv.value()...)
					*nest++
					result = mergeLinkAttribute(master, ls, result, nest)
					*nest--
				}
			}
			if *nest == 0 {
				for _, rv := range result {
					v.setLinkValues(rv)
				}
				result = map[string][]string{}
			}
		}
	}
	return result
}
849426
func GetUserTeams(c *m.ReqContext) Response {
	return getUserTeamList(c.OrgId, c.ParamsInt64(":id"))
}
731270
func (o *Ownership) IsUserAllowedByGroup(
	user *auth.UserInfo,
	accessType Ownership_AccessType,
) bool {

	// Allow if it is the admin user for any group
	if o.IsAdminByUser(user) {
		return true
	}

	ownergroups := o.GetGroups()
	if len(ownergroups) == 0 {
		return false
	}

	// Check each of the groups from the user
	for _, group := range user.Claims.Groups {
		// Check if the user group has permission
		if a, ok := ownergroups[group]; ok {
			return a.isAccessPermitted(accessType)
		}
	}

	// Check if any group is allowed
	if a, ok := ownergroups["*"]; ok {
		return a.isAccessPermitted(accessType)
	}

	return false
}
469650
func (ip *Interpreter) userGroups(args []string) {
	items, err := ip.Backend.UserGroups(args[0])
	ip.groupResponder(items, err)
}
650873
func (api UsersAPI) UpdateAvatarLink(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	oldLabel := mux.Vars(r)["label"]

	body := user.Avatar{}
	err := json.NewDecoder(r.Body).Decode(&body)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	newLabel := body.Label

	userMgr := user.NewManager(r)
	oldAvatar, errorOccurred := validateAvatarUpdateLabels(oldLabel, newLabel, username, userMgr, w)
	if errorOccurred {
		return
	}

	newAvatar := &user.Avatar{
		Label:  newLabel,
		Source: body.Source,
	}

	replaceAvatar(w, r, oldAvatar, newAvatar, username, userMgr)

}
419933
func Convert_v1_GroupList_To_user_GroupList(in *v1.GroupList, out *user.GroupList, s conversion.Scope) error {
	return autoConvert_v1_GroupList_To_user_GroupList(in, out, s)
}
996048
func (client *Client) UnlinkUserRichMenu(userID string) *UnlinkUserRichMenuCall {
	return &UnlinkUserRichMenuCall{
		c:      client,
		userID: userID,
	}
}
651363
func (api *Client) GetUserGroups(options ...GetUserGroupsOption) ([]UserGroup, error) {
	return api.GetUserGroupsContext(context.Background(), options...)
}
992041
func (g *SearchService) Users(uri *Hyperlink, uriParams M) (userSearchResults *UserSearchResults, result *Result) {
	url, err := ExpandWithDefault(uri, &UserSearchURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = g.client.get(url, &userSearchResults)
	return
}
137496
func (rtm *Client) UsersList() ([]User, error) {
	res := usersListResponse{}
	err := NewExternalRequest().
		AsPost().
		WithScheme(APIScheme).
		WithHost(APIEndpoint).
		WithPath("api/users.list").
		WithPostData("token", rtm.Token).
		JSON(&res)

	if err != nil {
		return nil, err
	}

	if !IsEmpty(res.Error) {
		return nil, exception.New(res.Error)
	}

	return res.Users, nil
}
1182186
func (o *Enterprise) Users(info *bambou.FetchingInfo) (UsersList, *bambou.Error) {

	var list UsersList
	err := bambou.CurrentSession().FetchChildren(o, UserIdentity, &list, info)
	return list, err
}
1257543
func (s *UserService) GetGroups(username string) (*[]UserGroup, *Response, error) {
	apiEndpoint := fmt.Sprintf("/rest/api/2/user/groups?username=%s", username)
	req, err := s.client.NewRequest("GET", apiEndpoint, nil)
	if err != nil {
		return nil, nil, err
	}

	userGroups := new([]UserGroup)
	resp, err := s.client.Do(req, userGroups)
	if err != nil {
		return nil, resp, NewJiraError(resp, err)
	}
	return userGroups, resp, nil
}
212033
func (h Handle) UnresolvedUsers() []keybase1.SocialAssertion {
	var unresolvedUsers []keybase1.SocialAssertion
	unresolvedUsers = append(unresolvedUsers, h.UnresolvedWriters...)
	unresolvedUsers = append(unresolvedUsers, h.UnresolvedReaders...)
	return unresolvedUsers
}
67086
func (r User_Permission_Group) UnlinkRole(role *datatypes.User_Permission_Role) (err error) {
	var resp datatypes.Void
	params := []interface{}{
		role,
	}
	err = r.Session.DoRequest("SoftLayer_User_Permission_Group", "unlinkRole", params, &r.Options, &resp)
	return
}
927186
func MyUserAndGroup() (uid int, gid int) {
	// Ask for the current user.
	user, err := user.Current()
	if err != nil {
		panic(err)
	}

	// Parse UID.
	uid64, err := strconv.ParseInt(user.Uid, 10, 32)
	if err != nil {
		log.Fatalf("Parsing UID (%s): %v", user.Uid, err)
		return
	}

	// Parse GID.
	gid64, err := strconv.ParseInt(user.Gid, 10, 32)
	if err != nil {
		log.Fatalf("Parsing GID (%s): %v", user.Gid, err)
		return
	}

	uid = int(uid64)
	gid = int(gid64)

	return
}
1260356
func (r *Client) AddActualOrgUser(userRole UserRole) (StatusMessage, error) {
	var (
		raw  []byte
		resp StatusMessage
		err  error
	)
	if raw, err = json.Marshal(userRole); err != nil {
		return StatusMessage{}, err
	}
	if raw, _, err = r.post("api/org/users", nil, raw); err != nil {
		return StatusMessage{}, err
	}
	if err = json.Unmarshal(raw, &resp); err != nil {
		return StatusMessage{}, err
	}
	return resp, nil
}
1270143
func (a *authenticator) AddPermissionGroup(group ...*access.PermissionGroup) {
	for _, newPermissionGroup := range group {
		if _, ok := a.groupDb[newPermissionGroup.Name]; ok {
			a.log.Warnf("permission group %s already exists, skipped")
			continue
		}
		a.log.Debugf("added HTTP permission group %s", newPermissionGroup.Name)
		a.groupDb[newPermissionGroup.Name] = newPermissionGroup.Permissions
	}
}