// RequireUser creates auth middleware with given configuration.
546415
func RequireUser(config *Config) func(http.Handler) http.Handler {
	config = config.SetDefaults()
	return func(next http.Handler) http.Handler {
		return &middleware{
			config: config,
			next:   next,
		}
	}
}
231999
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) {
	type userRequestBody struct {
		GUID string `json:"guid"`
	}

	bodyBytes, err := json.Marshal(userRequestBody{
		GUID: uaaUserID,
	})
	if err != nil {
		return User{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostUserRequest,
		Body:        bytes.NewReader(bodyBytes),
	})
	if err != nil {
		return User{}, nil, err
	}

	var user User
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &user,
	}

	err = client.connection.Make(request, &response)
	if err != nil {
		return User{}, response.Warnings, err
	}

	return user, response.Warnings, nil
}
337336
func (adm *AdminClient) AddUser(accessKey, secretKey string) error {
	return adm.SetUser(accessKey, secretKey, AccountEnabled)
}
78546
func RegisterUser(host, token string, doc map[string]interface{}) (*map[string]interface{}, error) {
	path := variables.APIPathRegisterUser
	return GenericRequest(host, path, token, doc)
}
388937
func (u *UserResource) createUser(request *restful.Request, response *restful.Response) {
	usr := User{Id: request.PathParameter("user-id")}
	err := request.ReadEntity(&usr)
	if err == nil {
		u.users[usr.Id] = usr
		response.WriteHeaderAndEntity(http.StatusCreated, usr)
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusInternalServerError, err.Error())
	}
}
739182
func (c *gitlabConnector) user(ctx context.Context, client *http.Client) (gitlabUser, error) {
	var u gitlabUser
	req, err := http.NewRequest("GET", c.baseURL+"/api/v4/user", nil)
	if err != nil {
		return u, fmt.Errorf("gitlab: new req: %v", err)
	}
	req = req.WithContext(ctx)
	resp, err := client.Do(req)
	if err != nil {
		return u, fmt.Errorf("gitlab: get URL %v", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return u, fmt.Errorf("gitlab: read body: %v", err)
		}
		return u, fmt.Errorf("%s: %s", resp.Status, body)
	}

	if err := json.NewDecoder(resp.Body).Decode(&u); err != nil {
		return u, fmt.Errorf("failed to decode response: %v", err)
	}
	return u, nil
}
481389
func newLoginLoadUser(g *libkb.GlobalContext, username string) *loginLoadUser {
	return &loginLoadUser{
		Contextified: libkb.NewContextified(g),
		username:     strings.TrimSpace(username),
	}
}
1046754
func (c *client) RegisterUser(user *User) {
	// Register with proper account and sublist.
	if user.Account != nil {
		if err := c.registerWithAccount(user.Account); err != nil {
			c.reportErrRegisterAccount(user.Account, err)
			return
		}
	}

	c.mu.Lock()
	defer c.mu.Unlock()

	// Assign permissions.
	if user.Permissions == nil {
		// Reset perms to nil in case client previously had them.
		c.perms = nil
		c.mperms = nil
		return
	}
	c.setPermissions(user.Permissions)
}
77054
func (u *ResourceCommand) createUser(client auth.ClientI, raw services.UnknownResource) error {
	user, err := services.GetUserMarshaler().UnmarshalUser(raw.Raw)
	if err != nil {
		return trace.Wrap(err)
	}
	userName := user.GetName()
	if err := client.UpsertUser(user); err != nil {
		return trace.Wrap(err)
	}
	fmt.Printf("user '%s' has been updated\n", userName)
	return nil
}
257158
func (v *Validator) Require(field string) *ValidationResult {
	if strings.TrimSpace(v.data.Get(field)) == "" {
		return v.addRequiredError(field)
	} else {
		return validationOk
	}
}
1185270
func (m *UserManager) createUser(user *User) error {
	email := sol.Select(
		Users.C("email"),
	).Where(Users.C("email").Equals(user.Email)).Limit(1)

	var duplicate string
	m.conn.Query(email, &duplicate)
	if duplicate != "" {
		return fmt.Errorf(
			"auth: user with email %s already exists", duplicate,
		)
	}

	// Insert the new user
	m.conn.Query(postgres.Insert(Users).Values(user).Returning(), user)
	return nil
}
825667
func (auth *Auth) CreateUser(email, first, last, clear string) (User, error) {
	return auth.users.Create(email, first, last, clear)
}
558507
func (cli *OpsGenieClient) User() (*OpsGenieUserClient, error) {
	cli.makeHTTPTransportSettings()

	userClient := new(OpsGenieUserClient)
	userClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		userClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return userClient, nil
}
33469
func (org *Organization) CreateUser(user NewUser) error {
	var (
		r accCreationResponse
		b bytes.Buffer
	)
	newUserL := []NewUser{user}
	err := json.NewEncoder(&b).Encode(newUserL)
	if err != nil {
		return err
	}
	err = org.PPE.post(fmt.Sprintf("/orgs/%s/users", org.PrimaryDomain), &b, &r)
	if err != nil {
		return err
	}
	if len(r.FailResults) > 0 {
		errs := make([]string, len(r.FailResults))
		for i, fr := range r.FailResults {
			errs[i] = fr.Result.Message
		}
		return errors.New(strings.Join(errs, ", "))
	}
	return nil
}
450898
func (c *Client) CreateUser(p *CreateUserParameter) (*User, error) {
	obj, err := c.Request("createUser", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*User), err
}
1099643
func (c *Client) User(userToken string) *UserClient {
	return &UserClient{
		UserToken: userToken,
		Client:    *c,
	}
}
306773
func ExpandUser(path string) string {
	if u, err := user.Current(); err == nil {
		return strings.Replace(path, "~", u.HomeDir, -1)
	}
	return path
}