// You should always use this function to get a new GetUserParams instance,
// as then you are sure you have configured all required params
345799
func (s *UserService) NewGetUserParams(userapikey string) *GetUserParams {
	p := &GetUserParams{}
	p.p = make(map[string]interface{})
	p.p["userapikey"] = userapikey
	return p
}
712368
func (s *UserService) EnableUser(p *EnableUserParams) (*EnableUserResponse, error) {
	resp, err := s.cs.newRequest("enableUser", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r EnableUserResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
274629
func (conn *Connection) GetUser(username string, userData interface{},
	auth Auth) (string, error) {
	userDb := conn.SelectDB("_users", auth)
	namestring := "org.couchdb.user:" + username
	return userDb.Read(namestring, &userData, nil)
}
604241
func buildURLParams(userURL string, params map[string]string) (string, error) {
	parsedURL, err := url.Parse(userURL)

	if err != nil {
		return "", err
	}

	parsedQuery, err := url.ParseQuery(parsedURL.RawQuery)

	if err != nil {
		return "", nil
	}

	for key, value := range params {
		parsedQuery.Set(key, value)
	}

	return addQueryParams(parsedURL, parsedQuery), nil
}
862043
func (s *UserService) UpdateUser(p *UpdateUserParams) (*UpdateUserResponse, error) {
	resp, err := s.cs.newRequest("updateUser", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateUserResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
912218
func (a *AuthServer) GetUsers() (users []services.User, err error) {
	return a.GetCache().GetUsers()
}
605627
func (o BoundOptions) getParameters() (params map[string]string, err error) {
	return map[string]string{
		"bounds": fmt.Sprintf("%v,%v|%v,%v",
			o.SwLatitude,
			o.SwLongitude,
			o.NeLatitude,
			o.NeLongitude,
		),
	}, nil
}
1214506
func GetUser(w http.ResponseWriter) (interface{}, bool) {
	usr, ok := GetResponseWriter(w, func(tst http.ResponseWriter) bool {
		_, ok := tst.(*userResponseWriter)
		return ok
	})
	if ok {
		return usr.(*userResponseWriter).user, true
	}
	return nil, false
}
807296
func getparams(str string) []string {
	var s []rune
	var j int
	var start bool
	var r []string
	var quoted int8
	for _, c := range str {
		if unicode.IsSpace(c) && quoted == 0 {
			if !start {
				continue
			} else {
				start = false
				j++
				r = append(r, string(s))
				s = make([]rune, 0)
				continue
			}
		}

		start = true
		if c == '"' {
			quoted ^= 1
			continue
		}
		s = append(s, c)
	}
	if len(s) > 0 {
		r = append(r, string(s))
	}
	return r
}
763050
func (c *Client) GetUser(token string) (*User, error) {
	req, err := c.NewRequest("GET", "/user", nil)
	if err != nil {
		return nil, err
	}

	tokenAuth(req, token)

	var u User

	_, err = c.Do(req, &u)
	if err != nil {
		return nil, err
	}

	return &u, nil
}
858981
func (m Map) GetParams(name string) (Params, bool) {
	if val, exist := m[name]; exist {
		if par, ok := val.(Params); ok {
			return par, ok
		}

		if par, ok := val.(map[string]interface{}); ok {
			return Map(par), ok
		}
	}

	return nil, false
}
965908
func (provider *SpotifyProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, spotifyEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
760421
func (api UsersAPI) GetUserInformation(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	userMgr := user.NewManager(r)

	userobj, err := userMgr.GetByName(username)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}

	requestingClient, validClient := context.Get(r, "client_id").(string)
	if !validClient {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	availableScopes, _ := context.Get(r, "availablescopes").(string)
	isAdmin := oauth2.CheckScopes([]string{"user:admin"}, oauth2.SplitScopeString(availableScopes))

	authorization, err := userMgr.GetAuthorization(username, requestingClient)
	if handleServerError(w, "getting authorization", err) {
		return
	}

	//Create an administrator authorization
	// TODO: rework for non admin scope in client credentials
	// if authorization is nil we are already assured that this is client credentials due to the middleware
	authorizedScopes := oauth2.SplitScopeString(availableScopes)
	if authorization == nil {
		authorization = &user.Authorization{
			// TODO: check bool values
			Name:                    false,
			Github:                  false,
			Facebook:                false,
			Addresses:               []user.AuthorizationMap{},
			BankAccounts:            []user.AuthorizationMap{},
			DigitalWallet:           []user.DigitalWalletAuthorization{},
			EmailAddresses:          []user.AuthorizationMap{},
			ValidatedEmailAddresses: []user.AuthorizationMap{},
			Phonenumbers:            []user.AuthorizationMap{},
			ValidatedPhonenumbers:   []user.AuthorizationMap{},
			PublicKeys:              []user.AuthorizationMap{},
			Avatars:                 []user.AuthorizationMap{},
			Organizations:           []string{},
		}
		_, all := filterAuthorizedInfo(authorizedScopes, "user:name")
		if isAdmin || all {
			authorization.Name = true
		}
		_, all = filterAuthorizedInfo(authorizedScopes, "user:github")
		if isAdmin || all {
			authorization.Github = true
		}
		_, all = filterAuthorizedInfo(authorizedScopes, "user:facebook")
		if isAdmin || all {
			authorization.Facebook = true
		}
		for _, address := range userobj.Addresses {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:address")
			if all || isAdmin {
				authorization.Addresses = append(authorization.Addresses, user.AuthorizationMap{RequestedLabel: address.Label, RealLabel: address.Label})
				continue
			}
			for _, label := range labels {
				if label == address.Label {
					authorization.Addresses = append(authorization.Addresses, user.AuthorizationMap{RequestedLabel: address.Label, RealLabel: address.Label})
				}
			}
		}
		for _, a := range userobj.BankAccounts {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:bankaccount")
			if all || isAdmin {
				authorization.BankAccounts = append(authorization.BankAccounts, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.BankAccounts = append(authorization.BankAccounts, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.DigitalWallet {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:digitalwalletaddress")
			if all || isAdmin {
				authorization.DigitalWallet = append(authorization.DigitalWallet, user.DigitalWalletAuthorization{Currency: a.CurrencySymbol, AuthorizationMap: user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label}})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.DigitalWallet = append(authorization.DigitalWallet, user.DigitalWalletAuthorization{Currency: a.CurrencySymbol, AuthorizationMap: user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label}})
				}
			}
		}
		for _, a := range userobj.EmailAddresses {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:email")
			if all || isAdmin {
				authorization.EmailAddresses = append(authorization.EmailAddresses, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.EmailAddresses = append(authorization.EmailAddresses, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.EmailAddresses {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:validated:email")
			if all || isAdmin {
				authorization.ValidatedEmailAddresses = append(authorization.ValidatedEmailAddresses, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.ValidatedEmailAddresses = append(authorization.ValidatedEmailAddresses, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.Phonenumbers {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:phone")
			if all || isAdmin {
				authorization.Phonenumbers = append(authorization.Phonenumbers, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.Phonenumbers = append(authorization.Phonenumbers, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.Phonenumbers {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:validated:phone")
			if all || isAdmin {
				authorization.ValidatedPhonenumbers = append(authorization.ValidatedPhonenumbers, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.ValidatedPhonenumbers = append(authorization.ValidatedPhonenumbers, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.PublicKeys {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:publickey")
			if all || isAdmin {
				authorization.PublicKeys = append(authorization.PublicKeys, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.PublicKeys = append(authorization.PublicKeys, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		for _, a := range userobj.Avatars {
			labels, all := filterAuthorizedInfo(authorizedScopes, "user:avatar")
			if all || isAdmin {
				authorization.Avatars = append(authorization.Avatars, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				continue
			}
			for _, label := range labels {
				if label == a.Label {
					authorization.Avatars = append(authorization.Avatars, user.AuthorizationMap{RequestedLabel: a.Label, RealLabel: a.Label})
				}
			}
		}
		labels, _ := filterAuthorizedInfo(authorizedScopes, "user:memberof")
		if len(labels) > 0 || isAdmin {
			userOrgs, err := organizationDb.NewManager(r).AllByUserChain(username)
			if handleServerError(w, "Getting user organizations", err) {
				return
			}
			for _, a := range userOrgs {
				if isAdmin {
					authorization.Organizations = append(authorization.Organizations, a)
					continue
				}
				for _, l := range labels {
					if l == a {
						authorization.Organizations = append(authorization.Organizations, a)
					}
				}
			}
		}

	}
	if authorization == nil {
		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
		return
	}

	respBody := &Userview{
		Username:                userobj.Username,
		Github:                  user.GithubAccount{},
		Facebook:                user.FacebookAccount{},
		Addresses:               []user.Address{},
		EmailAddresses:          []user.EmailAddress{},
		ValidatedEmailAddresses: []user.EmailAddress{},
		Phonenumbers:            []user.Phonenumber{},
		ValidatedPhonenumbers:   []user.Phonenumber{},
		BankAccounts:            []user.BankAccount{},
		DigitalWallet:           []user.DigitalAssetAddress{},
		OwnerOf: user.OwnerOf{
			EmailAddresses: []string{},
		},
		PublicKeys:    []user.PublicKey{},
		Avatars:       []user.Avatar{},
		Organizations: []string{},
	}

	if authorization.Name {
		respBody.Firstname = userobj.Firstname
		respBody.Lastname = userobj.Lastname
	}

	if authorization.Github {
		respBody.Github = userobj.Github
	}

	if authorization.Facebook {
		respBody.Facebook = userobj.Facebook
	}

	if authorization.Addresses != nil {
		for _, addressmap := range authorization.Addresses {
			address, err := userobj.GetAddressByLabel(addressmap.RealLabel)
			if err == nil {
				newaddress := user.Address{
					Label:      addressmap.RequestedLabel,
					City:       address.City,
					Country:    address.Country,
					Nr:         address.Nr,
					Other:      address.Other,
					Postalcode: address.Postalcode,
					Street:     address.Street,
				}
				respBody.Addresses = append(respBody.Addresses, newaddress)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.EmailAddresses != nil {
		for _, emailmap := range authorization.EmailAddresses {
			email, err := userobj.GetEmailAddressByLabel(emailmap.RealLabel)
			if err == nil {
				newemail := user.EmailAddress{
					Label:        emailmap.RequestedLabel,
					EmailAddress: email.EmailAddress,
				}
				respBody.EmailAddresses = append(respBody.EmailAddresses, newemail)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.Phonenumbers != nil {
		for _, phonemap := range authorization.Phonenumbers {
			phonenumber, err := userobj.GetPhonenumberByLabel(phonemap.RealLabel)
			if err == nil {
				newnumber := user.Phonenumber{
					Label:       phonemap.RequestedLabel,
					Phonenumber: phonenumber.Phonenumber,
				}
				respBody.Phonenumbers = append(respBody.Phonenumbers, newnumber)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.BankAccounts != nil {
		for _, bankmap := range authorization.BankAccounts {
			bank, err := userobj.GetBankAccountByLabel(bankmap.RealLabel)
			if err == nil {
				newbank := user.BankAccount{
					Label:   bankmap.RequestedLabel,
					Bic:     bank.Bic,
					Country: bank.Country,
					Iban:    bank.Iban,
				}
				respBody.BankAccounts = append(respBody.BankAccounts, newbank)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.DigitalWallet != nil {
		for _, addressMap := range authorization.DigitalWallet {
			walletAddress, err := userobj.GetDigitalAssetAddressByLabel(addressMap.RealLabel)
			if err == nil {
				walletAddress.Label = addressMap.RequestedLabel
				respBody.DigitalWallet = append(respBody.DigitalWallet, walletAddress)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.PublicKeys != nil {
		for _, publicKeyMap := range authorization.PublicKeys {
			publicKey, err := userobj.GetPublicKeyByLabel(publicKeyMap.RealLabel)
			if err == nil {
				publicKey.Label = publicKeyMap.RequestedLabel
				respBody.PublicKeys = append(respBody.PublicKeys, publicKey)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.Avatars != nil {
		for _, avatarMap := range authorization.Avatars {
			avatar, err := userobj.GetAvatarByLabel(avatarMap.RealLabel)
			if err == nil {
				avatar.Label = avatarMap.RequestedLabel
				respBody.Avatars = append(respBody.Avatars, avatar)
			} else {
				log.Debug(err)
			}
		}
	}

	if authorization.Organizations != nil {
		respBody.Organizations = authorization.Organizations
	}

	valMgr := validationdb.NewManager(r)
	if authorization.ValidatedEmailAddresses != nil {
		for _, validatedEmailMap := range authorization.ValidatedEmailAddresses {
			email, err := userobj.GetEmailAddressByLabel(validatedEmailMap.RealLabel)
			if err == nil {
				validated, err := valMgr.IsEmailAddressValidated(authorization.Username, email.EmailAddress)
				if err != nil {
					log.Error("Failed to verify if email address is validated for this user: ", err)
					continue
				}
				if !validated {
					continue
				}
				email.Label = validatedEmailMap.RequestedLabel
				respBody.ValidatedEmailAddresses = append(respBody.ValidatedEmailAddresses, email)
			} else {
				log.Debug(err)
			}
		}

		if authorization.ValidatedPhonenumbers != nil {
			for _, validatedPhoneMap := range authorization.ValidatedPhonenumbers {
				phone, err := userobj.GetPhonenumberByLabel(validatedPhoneMap.RealLabel)
				if err == nil {
					validated, err := valMgr.IsPhonenumberValidated(authorization.Username, phone.Phonenumber)
					if err != nil {
						log.Error("Failed to verify if phone number is validated for this user: ", err)
						continue
					}
					if !validated {
						continue
					}
					phone.Label = validatedPhoneMap.RequestedLabel
					respBody.ValidatedPhonenumbers = append(respBody.ValidatedPhonenumbers, phone)
				} else {
					log.Debug(err)
				}
			}
		}
	}

	if authorization.OwnerOf.EmailAddresses != nil {
		respBody.OwnerOf.EmailAddresses = authorization.OwnerOf.EmailAddresses
	}

	w.Header().Set("Content-Type", "application/json")
	json.NewEncoder(w).Encode(respBody)
}
331820
func (s *IdentityService) GetUsers() ([]services.User, error) {
	startKey := backend.Key(webPrefix, usersPrefix)
	result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var out []services.User
	for _, item := range result.Items {
		if !bytes.HasSuffix(item.Key, []byte(paramsPrefix)) {
			continue
		}
		u, err := services.GetUserMarshaler().UnmarshalUser(
			item.Value, services.WithResourceID(item.ID), services.WithExpires(item.Expires))
		if err != nil {
			return nil, trace.Wrap(err)
		}
		out = append(out, u)
	}
	return out, nil
}
530172
func GetParams(name string, r *http.Request) []string {
	if params := r.Context().Value(ParamsKey); params != nil {
		params := params.(Params)
		if name != "*" {
			name = ":" + name
		}
		if param := params[name]; param != nil {
			switch param := param.(type) {
			case []string:
				return param
			default:
				return []string{param.(string)}
			}
		}
	}
	return []string{}
}
904703
func (a *API) GetUser(user int) (*User, error) {
	dst := new(User)
	url := a.BuildURL("/v2/user/%d", user)
	err := a.Get(url, Params{}, dst)
	return dst, err
}
1177967
func GetUserInfo(user *nerdz.User) *UserInfo {
	var info UserInfo
	info.Info = user.Info().GetTO()
	info.Contacts = user.ContactInfo().GetTO()
	info.Personal = user.PersonalInfo().GetTO()
	return &info
}