// DeleteUser issues the nimbusec API to delete an user. The root user or tennant
// can not be deleted via this method.
171993
func (a *API) DeleteUser(user *User) error {
	url := a.BuildURL("/v2/user/%d", user.Id)
	return a.Delete(url, Params{})
}
1218911
func DeleteUser(c *context.APIContext) {
	u := user.GetUserByParams(c)
	if c.Written() {
		return
	}

	if err := models.DeleteUser(u); err != nil {
		if models.IsErrUserOwnRepos(err) ||
			models.IsErrUserHasOrgs(err) {
			c.Error(422, "", err)
		} else {
			c.Error(500, "DeleteUser", err)
		}
		return
	}
	log.Trace("Account deleted by admin(%s): %s", c.User.Name, u.Name)

	c.Status(204)
}
1117761
func (b MongodbAuthBackend) DeleteUser(username string) error {
	c := b.connect()
	defer c.Database.Session.Close()

	// raises error if "username" doesn't exist
	err := c.Remove(bson.M{"Username": username})
	if err == mgo.ErrNotFound {
		return ErrDeleteNull
	}
	return err
}
316730
func (s *UserService) DeleteUser(ctx context.Context, id influxdb.ID) error {
	url, err := newURL(s.Addr, userIDPath(id))
	if err != nil {
		return err
	}

	req, err := http.NewRequest("DELETE", url.String(), nil)
	if err != nil {
		return err
	}
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	return CheckErrorStatus(http.StatusNoContent, resp)
}
4775
func (c *UsersProfileSetCall) User(user string) *UsersProfileSetCall {
	c.user = user
	return c
}
874882
func DeleteIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) error {
	return client.delete("/Services/" + serviceSid + "/Users/" + sid)
}
1188027
func (s *cheServiceImpl) DeleteUser(ctx context.Context, identity repository.Identity) error {
	log.Info(ctx, map[string]interface{}{"identity_id": identity.ID.String()}, "deleting user on Che service")
	// this endpoint is restricted to the `auth` Service Account
	deleteUserAPIURL := fmt.Sprintf("%s/api/user/%s", s.config.GetCheServiceURL(), identity.ID.String())
	req, err := http.NewRequest("DELETE", deleteUserAPIURL, nil)
	if err != nil {
		return errs.Wrapf(err, "unable to delete user '%s' in Che", identity.ID.String())
	}

	tokenManager, err := manager.DefaultManager(s.config)
	if err != nil {
		return errs.Wrapf(err, "unable to delete user '%s' in Che", identity.ID.String())
	}

	token, err := tokenManager.GenerateTransientUserAccessTokenForIdentity(ctx, identity)
	if err != nil {
		return errs.Wrapf(err, "unable to delete user '%s' in Che", identity.ID.String())
	}

	_, err = s.Services().TokenService().RegisterToken(ctx, identity.ID, *token, token2.TOKEN_TYPE_ACCESS, nil)
	if err != nil {
		return errs.Wrapf(err, "unable to delete user '%s' in Che", identity.ID.String())
	}

	req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", *token))
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		return errs.Wrapf(err, "unable to delete user '%s' in Che", identity.ID.String())
	}

	defer rest.CloseResponse(res)
	bodyString := rest.ReadBody(res.Body) // To prevent FDs leaks

	switch res.StatusCode {
	case http.StatusNoContent:
		// OK
		return nil
	case http.StatusNotFound:
		// May happen if the user has been already deleted from Che
		// Log the error but return OK
		log.Warn(ctx, map[string]interface{}{
			"identity_id":     identity.ID.String(),
			"response_status": res.Status,
			"response_body":   bodyString,
		}, "unable to delete user in Che which is OK if user already deleted from Che")
		return nil
	}

	log.Error(ctx, map[string]interface{}{
		"identity_id":     identity.ID.String(),
		"response_status": res.Status,
		"response_body":   bodyString,
	}, "unable to delete user in Che")
	return errors.NewInternalErrorFromString(ctx, fmt.Sprintf("unable to delete user '%s' in Che", identity.ID.String()))
}
479187
func (api UsersAPI) DeleteUserRegistryEntry(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	key := mux.Vars(r)["key"]

	mgr := registry.NewManager(r)
	err := mgr.DeleteRegistryEntry(username, "", key)

	if err != nil {
		log.Error(err.Error())
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.WriteHeader(http.StatusNoContent)
}
358590
func (c *UserStore) Delete(ctx context.Context, u *chronograf.User) error {
	return c.Ctrl.DeleteUser(ctx, u.Name)
}
129245
func (state *UserState) RemoveUser(username string) {
	state.usernames.Del(username)
	// Remove additional data as well
	// TODO: Ideally, remove all keys belonging to the user.
	state.users.DelKey(username, "loggedin")
}
1367046
func (c *UsersProfileGetCall) User(user string) *UsersProfileGetCall {
	c.user = user
	return c
}
1027096
func (c Config) User(ctx context.Context) (string, string, bool) {
	return ctx.Request().BasicAuth()
}
1370995
func (m *Manager) RemoveUser(globalID string, username string) error {
	qry := bson.M{"globalid": globalID}
	update := bson.M{"$pull": bson.M{"owners": username, "members": username}}
	return m.collection.Update(qry, update)
}
316622
func RemoveUser(file, user string) error {
	passwords, err := ParseHtpasswdFile(file)
	if err != nil {
		return err
	}
	_, ok := passwords[user]
	if !ok {
		return ErrNotExist
	}
	delete(passwords, user)
	return passwords.WriteToFile(file)
}
154254
func (ip *Interpreter) deleteUser(args []string) {
	ip.simpleResponder(ip.Backend.DeleteUser(args[0]))
}
709932
func (s *UserService) DeleteUser(ctx context.Context, id influxdb.ID) error {
	if err := authorizeWriteUser(ctx, id); err != nil {
		return err
	}

	return s.s.DeleteUser(ctx, id)
}
728266
func (l *labelIdentitySelector) removeUser(user CachedSelectionUser) (last bool) {
	delete(l.users, user)
	return len(l.users) == 0
}