// Delete a user.
506299
func (m *Manager) Delete(u *User) error {
	if u.ID == "" {
		return errors.New("User not stored")
	}

	return m.getUserCollection().RemoveId(u.ID)
}
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
}
753071
func (e *Enforcer) DeletePermissionForUser(user string, permission ...string) bool {
	params := make([]interface{}, 0, len(permission)+1)

	params = append(params, user)
	for _, perm := range permission {
		params = append(params, perm)
	}

	return e.RemovePolicy(params...)
}
1174694
func (s *UserService) NewDeleteUserParams(id string) *DeleteUserParams {
	p := &DeleteUserParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
527238
func Delete(c *client.Client, appID string, username string) error {
	return doDelete(c, fmt.Sprintf("/v1/apps/%s/perms/%s", appID, username))
}
1222279
func NewDeleteUser(ctx *middleware.Context, handler DeleteUserHandler) *DeleteUser {
	return &DeleteUser{Context: ctx, Handler: handler}
}
977748
func Delete(c *client.Client, username string) error {
	var body []byte
	var err error

	if username != "" {
		req := api.AuthCancelRequest{Username: username}
		body, err = json.Marshal(req)

		if err != nil {
			return err
		}
	}

	_, err = c.BasicRequest("DELETE", "/v1/auth/cancel/", body)
	return err
}
831096
func (s *Service) DeleteUser(ctx context.Context, id platform.ID) error {
	if _, err := s.FindUserByID(ctx, id); err != nil {
		return &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpDeleteUser,
		}
	}
	s.userKV.Delete(id.String())
	return nil
}
459194
func (s *Service) RemoveUser(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	idStr := httprouter.GetParamFromContext(ctx, "id")
	id, err := strconv.ParseUint(idStr, 10, 64)
	if err != nil {
		Error(w, http.StatusBadRequest, fmt.Sprintf("invalid user id: %s", err.Error()), s.Logger)
		return
	}

	u, err := s.Store.Users(ctx).Get(ctx, chronograf.UserQuery{ID: &id})
	if err != nil {
		Error(w, http.StatusNotFound, err.Error(), s.Logger)
		return
	}
	if err := s.Store.Users(ctx).Delete(ctx, u); err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	w.WriteHeader(http.StatusNoContent)
}
305891
func (c *Client) RemoveUser(name string) error {
	return c.delete(nil, "/user/"+name)
}
204385
func (s *UsersStore) Delete(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 {
		return tx.Bucket(UsersBucket).Delete(u64tob(u.ID))
	})
}
876722
func (s *KeyGen) Delete(user string) (err error) {
	var apikey string

	if apikey, err = s.Get(user); err == nil {
		_, err = s.store().Do("DEL", createHash(user, apikey))
	}
	return
}
581446
func (u *UserResource) removeUser(request *restful.Request, response *restful.Response) {
	id := request.PathParameter("user-id")
	delete(u.users, id)
}
1021757
func (user *User) Delete(message existingMessage) error {
	if user.CanDelete(message) {
		return Db().Delete(message)
	}
	return errors.New("You can't delete this message")
}
389849
func (api OrganizationsAPI) DeleteUserGrant(w http.ResponseWriter, r *http.Request) {
	globalid := mux.Vars(r)["globalid"]
	userIdentifier := mux.Vars(r)["username"]
	grantString := mux.Vars(r)["grant"]

	grant := grants.Grant(grantString)

	userObj, err := SearchUser(r, userIdentifier)
	if err != nil && !db.IsNotFound(err) {
		log.Error("Failed to look up user identifier: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if err != nil {
		// No user found for this identifier, since the user thus no longer has the grant requested
		// for removal, we can also return a 204 here
		w.WriteHeader(http.StatusNoContent)
		return
	}

	hasAuth, err := hasAuthorization(r, userObj.Username, globalid)
	if handleServerError(w, "checking if user has an authorization for the organization", err) {
		return
	}
	if !hasAuth {
		log.Debug("Refusing to delete grant for user without authorization")
		w.WriteHeader(http.StatusForbidden)
		w.Write([]byte("User does not have an authorization for this organzation"))
		return
	}

	grantMgr := grants.NewManager(r)
	err = grantMgr.DeleteUserGrant(userObj.Username, globalid, grant)
	if err != nil && !db.IsNotFound(err) {
		log.Error("Failed to delete user grant: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.WriteHeader(http.StatusNoContent)
}
171993
func (a *API) DeleteUser(user *User) error {
	url := a.BuildURL("/v2/user/%d", user.Id)
	return a.Delete(url, Params{})
}
728266
func (l *labelIdentitySelector) removeUser(user CachedSelectionUser) (last bool) {
	delete(l.users, user)
	return len(l.users) == 0
}