// ConvertUsersSimple converts a array of simple Identity IDs into a Generic Reletionship List
557183
func ConvertUsersSimple(request *goa.RequestData, identityIDs []interface{}) []*app.GenericData {
	var ops []*app.GenericData
	for _, identityID := range identityIDs {
		ops = append(ops, ConvertUserSimple(request, identityID))
	}
	return ops
}
291404
func (id *PolicyEvaluator) DeserializeIdentity(serializedIdentity []byte) (Identity, error) {
	mspIdentity, err := id.IdentityDeserializer.DeserializeIdentity(serializedIdentity)
	if err != nil {
		return nil, err
	}
	return &identity{Identity: mspIdentity}, nil
}
1230526
func ConvertCodebaseSimple(request *http.Request, id interface{}) (*app.GenericData, *app.GenericLinks) {
	i := fmt.Sprint(id)
	data := &app.GenericData{
		Type: ptr.String(APIStringTypeCodebase),
		ID:   &i,
	}
	relatedURL := rest.AbsoluteURL(request, app.CodebaseHref(i))
	links := &app.GenericLinks{
		Self:    &relatedURL,
		Related: &relatedURL,
	}
	return data, links
}
446021
func Convert_v1alpha2_UserData_To_kops_UserData(in *UserData, out *kops.UserData, s conversion.Scope) error {
	return autoConvert_v1alpha2_UserData_To_kops_UserData(in, out, s)
}
1172208
func unsetIdentityUser(identity *userapi.Identity) bool {
	if !hasUserMapping(identity) {
		return false
	}
	identity.User = corev1.ObjectReference{}
	return true
}
766073
func (api OrganizationsAPI) ListUsersWithGrant(w http.ResponseWriter, r *http.Request) {
	globalID := mux.Vars(r)["globalid"]
	grantString := mux.Vars(r)["grant"]

	grant := grants.Grant(grantString)
	if err := grant.Validate(); err != nil {
		log.Debug("Invalid grant: ", err)
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	grantMgr := grants.NewManager(r)
	grantObjs, err := grantMgr.GetByGrant(grant, globalID)
	if err != nil && !db.IsNotFound(err) {
		log.Error("Failed to look up users with grant: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	usernames := []string{}
	for _, grantObj := range grantObjs {
		usernames = append(usernames, grantObj.Username)
	}

	log.Debug("filtering users to those with an open authorization")
	usernames, err = user.NewManager(r).FilterUsersWithAuthorizations(usernames, globalID)
	if handleServerError(w, "filtering out users without authorization", err) {
		return
	}

	userIdentifiers, err := organization.ConvertUsernamesToIdentifiers(usernames, validationdb.NewManager(r))
	if err != nil {
		log.Error("Failed to convert usernames to identifiers: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	json.NewEncoder(w).Encode(userIdentifiers)
}
1131123
func Convert_kops_UserData_To_v1alpha2_UserData(in *kops.UserData, out *UserData, s conversion.Scope) error {
	return autoConvert_kops_UserData_To_v1alpha2_UserData(in, out, s)
}
18402
func loadDefaultIdpIdentities(repos repository.Repositories, users []accountrepo.User) ([]accountrepo.User, []accountrepo.Identity, error) {
	var resultUsers []accountrepo.User
	var resultIdentities []accountrepo.Identity
	for _, user := range users {
		identity, err := loadDefaultIdpIdentity(repos, user)
		// if we can't find the default IDP identity
		if err != nil {
			log.Error(nil, map[string]interface{}{"user": user, "err": err}, "unable to load user default IDP identity")
		} else {
			resultUsers = append(resultUsers, user)
			resultIdentities = append(resultIdentities, *identity)
		}
	}
	return resultUsers, resultIdentities, nil
}
643191
func (user *User) UserHome(options PostlistOptions) *[]UserPost {
	var userPost UserPost

	query := Db().Model(userPost).Order("hpid DESC")
	query = query.Where("("+UserPost{}.TableName()+`."to" NOT IN (SELECT "to" FROM blacklist WHERE "from" = ?))`, user.ID())

	options.Model = userPost
	query = postlistQueryBuilder(query, options, user)

	var posts []UserPost
	query.Scan(&posts)
	return &posts
}
1034575
func Convert_user_IdentityList_To_v1_IdentityList(in *user.IdentityList, out *v1.IdentityList, s conversion.Scope) error {
	return autoConvert_user_IdentityList_To_v1_IdentityList(in, out, s)
}
180544
func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error) {
	userIdentifier := username
	usr, err := usrMgr.GetByName(username)
	if err != nil {
		return userIdentifier, err
	}
	// check for a validated email address
	for _, email := range usr.EmailAddresses {
		validated, err := valMgr.IsEmailAddressValidated(username, email.EmailAddress)
		if err != nil {
			return userIdentifier, err
		}
		if validated {
			return email.EmailAddress, err
		}
	}
	// try the phone numbers
	for _, phone := range usr.Phonenumbers {
		validated, err := valMgr.IsPhonenumberValidated(username, phone.Phonenumber)
		if err != nil {
			return userIdentifier, err
		}
		if validated {
			return phone.Phonenumber, err
		}
	}
	// No verified email or phone number. Fallback to username
	return userIdentifier, err
}
581446
func (u *UserResource) removeUser(request *restful.Request, response *restful.Response) {
	id := request.PathParameter("user-id")
	delete(u.users, id)
}
1018648
func (l *State) ToUserData(index int) interface{} {
	if d, ok := l.indexToValue(index).(*userData); ok {
		return d.data
	}
	return nil
}
20416
func parseUserFromImageUser(id string) string {
	if id == "" {
		return id
	}
	// split instances where the id may contain user:group
	if strings.Contains(id, ":") {
		return strings.Split(id, ":")[0]
	}
	// no group, just return the id
	return id
}
1159722
func Convert_v1_IdentityProvider_To_config_IdentityProvider(in *legacyconfigv1.IdentityProvider, out *internal.IdentityProvider, s conversion.Scope) error {
	if err := autoConvert_v1_IdentityProvider_To_config_IdentityProvider(in, out, s); err != nil {
		return err
	}

	if len(in.Provider.Raw) == 0 && (in.Provider.Object == nil) {
		out.Provider = nil
	} else {
		if err := convert_runtime_RawExtension_To_runtime_Object(&in.Provider, &out.Provider, s); err != nil {
			return nil
		}
	}

	return nil
}
211342
func Convert_user_Identity_To_v1_Identity(in *user.Identity, out *v1.Identity, s conversion.Scope) error {
	return autoConvert_user_Identity_To_v1_Identity(in, out, s)
}
1091630
func IdentityFilterByUserID(userID uuid.UUID) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("user_id = ?", userID)
	}
}