Fabi 1143e3773e
fix: Remove user with cascading memberships (#1811)
* fix: remove usermemberships on user remove

* fix: text user remove with memberships

* fix: translations

* Update internal/iam/repository/eventsourcing/model/types.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: uncomment tests

* fix: remove memberships if user removed

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-06-07 07:20:47 +02:00

83 lines
3.1 KiB
Go

package view
import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v1/models"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/project/repository/view"
"github.com/caos/zitadel/internal/project/repository/view/model"
"github.com/caos/zitadel/internal/view/repository"
)
const (
projectGrantMemberTable = "management.project_grant_members"
)
func (v *View) ProjectGrantMemberByIDs(projectID, userID string) (*model.ProjectGrantMemberView, error) {
return view.ProjectGrantMemberByIDs(v.Db, projectGrantMemberTable, projectID, userID)
}
func (v *View) ProjectGrantMembersByProjectID(projectID string) ([]*model.ProjectGrantMemberView, error) {
return view.ProjectGrantMembersByProjectID(v.Db, projectGrantMemberTable, projectID)
}
func (v *View) SearchProjectGrantMembers(request *proj_model.ProjectGrantMemberSearchRequest) ([]*model.ProjectGrantMemberView, uint64, error) {
return view.SearchProjectGrantMembers(v.Db, projectGrantMemberTable, request)
}
func (v *View) ProjectGrantMembersByUserID(userID string) ([]*model.ProjectGrantMemberView, error) {
return view.ProjectGrantMembersByUserID(v.Db, projectGrantMemberTable, userID)
}
func (v *View) PutProjectGrantMember(member *model.ProjectGrantMemberView, event *models.Event) error {
err := view.PutProjectGrantMember(v.Db, projectGrantMemberTable, member)
if err != nil {
return err
}
return v.ProcessedProjectGrantMemberSequence(event)
}
func (v *View) PutProjectGrantMembers(members []*model.ProjectGrantMemberView, event *models.Event) error {
err := view.PutProjectGrantMembers(v.Db, projectGrantMemberTable, members...)
if err != nil {
return err
}
return v.ProcessedProjectGrantMemberSequence(event)
}
func (v *View) DeleteProjectGrantMember(grantID, userID string, event *models.Event) error {
err := view.DeleteProjectGrantMember(v.Db, projectGrantMemberTable, grantID, userID)
if err != nil && !errors.IsNotFound(err) {
return err
}
return v.ProcessedProjectGrantMemberSequence(event)
}
func (v *View) DeleteProjectGrantMembersByProjectID(projectID string) error {
return view.DeleteProjectGrantMembersByProjectID(v.Db, projectGrantMemberTable, projectID)
}
func (v *View) DeleteProjectGrantMembersByUserID(userID string) error {
return view.DeleteProjectGrantMembersByUserID(v.Db, projectGrantMemberTable, userID)
}
func (v *View) GetLatestProjectGrantMemberSequence() (*repository.CurrentSequence, error) {
return v.latestSequence(projectGrantMemberTable)
}
func (v *View) ProcessedProjectGrantMemberSequence(event *models.Event) error {
return v.saveCurrentSequence(projectGrantMemberTable, event)
}
func (v *View) UpdateProjectGrantMemberSpoolerRunTimestamp() error {
return v.updateSpoolerRunSequence(projectGrantMemberTable)
}
func (v *View) GetLatestProjectGrantMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
return v.latestFailedEvent(projectGrantMemberTable, sequence)
}
func (v *View) ProcessedProjectGrantMemberFailedEvent(failedEvent *repository.FailedEvent) error {
return v.saveFailedEvent(failedEvent)
}