// UpdateUser updates an existing user
320687
func (auth *Auth) UpdateUser(ctx context.Context, user *User) error {
	_, err := auth.client.SetAccountInfo(&identitytoolkit.IdentitytoolkitRelyingpartySetAccountInfoRequest{
		LocalId:       user.UserID,
		Email:         user.Email,
		EmailVerified: user.EmailVerified,
		Password:      user.Password,
		DisplayName:   user.DisplayName,
		DisableUser:   user.Disabled,
		PhotoUrl:      user.PhotoURL,
		PhoneNumber:   user.PhoneNumber,
	}).Context(ctx).Do()
	if err != nil {
		return err
	}
	return nil
}
299748
func (s *ActivateUserOutput) SetUser(v *User) *ActivateUserOutput {
	s.User = v
	return s
}
1270221
func (s *userService) UpdatePassword(id int64, newPassword string) (datamodels.User, error) {
	// update the user and return it.
	hashed, err := datamodels.GeneratePassword(newPassword)
	if err != nil {
		return datamodels.User{}, err
	}

	return s.Update(id, datamodels.User{
		HashedPassword: hashed,
	})
}
1062743
func (c *Client) Update(ctx context.Context, u *chronograf.User) error {
	// Only allow one type of change at a time. If it is a password
	// change then do it and return without any changes to permissions
	if u.Passwd != "" {
		return c.updatePassword(ctx, u.Name, u.Passwd)
	}

	user, err := c.Get(ctx, chronograf.UserQuery{Name: &u.Name})
	if err != nil {
		return err
	}

	revoke, add := Difference(u.Permissions, user.Permissions)
	for _, a := range add {
		if err := c.grantPermission(ctx, u.Name, a); err != nil {
			return err
		}
	}

	for _, r := range revoke {
		if err := c.revokePermission(ctx, u.Name, r); err != nil {
			return err
		}
	}
	return nil
}
22403
func (s *Service) UpdateUser(ctx context.Context, id platform.ID, upd platform.UserUpdate) (*platform.User, error) {
	o, err := s.FindUserByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpUpdateUser,
		}
	}

	if upd.Name != nil {
		o.Name = *upd.Name
	}

	s.userKV.Store(o.ID.String(), o)

	return o, nil
}
635866
func (s *EndpointBatchItem) SetUser(v *EndpointUser) *EndpointBatchItem {
	s.User = v
	return s
}
795222
func (c *Client) SetUser(u string) *Client {
	c.Username = u
	return c
}
363152
func (s *userService) UpdateUsername(id int64, newUsername string) (datamodels.User, error) {
	return s.Update(id, datamodels.User{
		Username: newUsername,
	})
}
685206
func (s *UsersService) UpdatePassword(username string, body UsersUsernamePasswordPutReqBody, headers, queryParams map[string]interface{}) (*http.Response, error) {
	var err error

	resp, err := s.client.doReqWithBody("PUT", s.client.BaseURI+"/users/"+username+"/password", &body, headers, queryParams)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	switch resp.StatusCode {
	case 422:
		var respBody422 Error
		err = goraml.NewAPIError(resp, &respBody422)
	default:
		err = goraml.NewAPIError(resp, nil)
	}

	return resp, err
}
524905
func (s *UsersStore) Update(ctx context.Context, u *chronograf.User) error {
	_, err := s.get(ctx, u.ID)
	if err != nil {
		return err
	}
	return s.client.db.Update(func(tx *bolt.Tx) error {
		if v, err := internal.MarshalUser(u); err != nil {
			return err
		} else if err := tx.Bucket(UsersBucket).Put(u64tob(u.ID), v); err != nil {
			return err
		}
		return nil
	})
}
118725
func (p *Pod) SetUser(user string) *Pod {
	p.User = user
	return p
}
1367931
func (s *DescribeUserOutput) SetUser(v *DescribedUser) *DescribeUserOutput {
	s.User = v
	return s
}
724366
func (m *MetaClient) CreateUpdateUser(ctx context.Context, action, name, passwd string) error {
	a := &UserAction{
		Action: action,
		User: &User{
			Name:     name,
			Password: passwd,
		},
	}
	return m.Post(ctx, "/user", a, nil)
}
1153408
func (c *ExampleService) PutUser(ctx context.Context, u *platform.User) error {
	return c.kv.Update(func(tx Tx) error {
		return c.putUser(ctx, tx, u)
	})
}
1134039
func (s *PublicEndpoint) SetUser(v *EndpointUser) *PublicEndpoint {
	s.User = v
	return s
}
980915
func (u *UserResource) updateUser(request *restful.Request, response *restful.Response) {
	usr := new(User)
	err := request.ReadEntity(&usr)
	if err == nil {
		u.users[usr.Id] = *usr
		response.WriteEntity(usr)
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusInternalServerError, err.Error())
	}
}
16753
func (f *Facade) UpdateUser(ctx datastore.Context, user userdomain.User) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateUser"))
	var err error
	logger := plog.WithField("userName", user.Name)
	logger.Debug("Started Facade.UpdateUser")
	defer logger.WithError(err).Debug("Finished Facade.UpdateUser")

	id := strings.TrimSpace(user.Name)
	if id == "" {
		err = errors.New("empty User.Name not allowed")
		return err
	}

	user.Name = id
	user.Password = hashPassword(user.Password)
	err = f.userStore.Put(ctx, userdomain.Key(user.Name), &user)
	return err
}