mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-18 07:15:00 +00:00
feat: delete (#243)
* feat: project role remove * feat: search queries * feat: search queries * feat: cascade remove/change project role * fix: comment in project grant * fix: remove projecr grant * fix: only search usergrants of my org * fix: delete usergrants * fix: delete usergrants * fix: check if role exists on project grant * feat: bulk add project role * fix: tests * fix: update user grants on project update * fix: return roles * feat: add resourceowner name on project grants * fix: migration number * fix: tests * fix: generate protos * fix: some unnecessary code
This commit is contained in:
@@ -17,20 +17,22 @@ const (
|
||||
ProjectGrantKeyOrgID = "org_id"
|
||||
ProjectGrantKeyResourceOwner = "resource_owner"
|
||||
ProjectGrantKeyName = "project_name"
|
||||
ProjectGrantKeyRoleKeys = "granted_role_keys"
|
||||
)
|
||||
|
||||
type ProjectGrantView struct {
|
||||
GrantID string `json:"-" gorm:"column:grant_id;primary_key"`
|
||||
ProjectID string `json:"-" gorm:"column:project_id"`
|
||||
OrgID string `json:"-" gorm:"column:org_id"`
|
||||
Name string `json:"name" gorm:"column:project_name"`
|
||||
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
||||
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||
State int32 `json:"-" gorm:"column:project_state"`
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
OrgName string `json:"-" gorm:"column:org_name"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
GrantedRoleKeys pq.StringArray `json:"-" gorm:"column:granted_role_keys"`
|
||||
GrantID string `json:"-" gorm:"column:grant_id;primary_key"`
|
||||
ProjectID string `json:"-" gorm:"column:project_id"`
|
||||
OrgID string `json:"-" gorm:"column:org_id"`
|
||||
Name string `json:"name" gorm:"column:project_name"`
|
||||
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
|
||||
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||
State int32 `json:"-" gorm:"column:project_state"`
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
ResourceOwnerName string `json:"-" gorm:"column:resource_owner_name"`
|
||||
OrgName string `json:"-" gorm:"column:org_name"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
GrantedRoleKeys pq.StringArray `json:"-" gorm:"column:granted_role_keys"`
|
||||
}
|
||||
|
||||
type ProjectGrant struct {
|
||||
@@ -41,32 +43,35 @@ type ProjectGrant struct {
|
||||
|
||||
func ProjectGrantFromModel(project *model.ProjectGrantView) *ProjectGrantView {
|
||||
return &ProjectGrantView{
|
||||
ProjectID: project.ProjectID,
|
||||
OrgID: project.OrgID,
|
||||
Name: project.Name,
|
||||
ChangeDate: project.ChangeDate,
|
||||
CreationDate: project.CreationDate,
|
||||
State: int32(project.State),
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
OrgName: project.OrgName,
|
||||
GrantID: project.GrantID,
|
||||
GrantedRoleKeys: project.GrantedRoleKeys,
|
||||
Sequence: project.Sequence,
|
||||
ProjectID: project.ProjectID,
|
||||
OrgID: project.OrgID,
|
||||
Name: project.Name,
|
||||
ChangeDate: project.ChangeDate,
|
||||
CreationDate: project.CreationDate,
|
||||
State: int32(project.State),
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
ResourceOwnerName: project.ResourceOwnerName,
|
||||
OrgName: project.OrgName,
|
||||
GrantID: project.GrantID,
|
||||
GrantedRoleKeys: project.GrantedRoleKeys,
|
||||
Sequence: project.Sequence,
|
||||
}
|
||||
}
|
||||
|
||||
func ProjectGrantToModel(project *ProjectGrantView) *model.ProjectGrantView {
|
||||
return &model.ProjectGrantView{
|
||||
ProjectID: project.ProjectID,
|
||||
OrgID: project.OrgID,
|
||||
Name: project.Name,
|
||||
ChangeDate: project.ChangeDate,
|
||||
CreationDate: project.CreationDate,
|
||||
State: model.ProjectState(project.State),
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
OrgName: project.OrgName,
|
||||
GrantID: project.GrantID,
|
||||
Sequence: project.Sequence,
|
||||
ProjectID: project.ProjectID,
|
||||
OrgID: project.OrgID,
|
||||
Name: project.Name,
|
||||
ChangeDate: project.ChangeDate,
|
||||
CreationDate: project.CreationDate,
|
||||
State: model.ProjectState(project.State),
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
ResourceOwnerName: project.ResourceOwnerName,
|
||||
OrgName: project.OrgName,
|
||||
GrantID: project.GrantID,
|
||||
Sequence: project.Sequence,
|
||||
GrantedRoleKeys: project.GrantedRoleKeys,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +92,7 @@ func (p *ProjectGrantView) AppendEvent(event *models.Event) (err error) {
|
||||
p.CreationDate = event.CreationDate
|
||||
p.setRootData(event)
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantChanged:
|
||||
case es_model.ProjectGrantChanged, es_model.ProjectGrantCascadeChanged:
|
||||
err = p.setProjectGrantData(event)
|
||||
case es_model.ProjectGrantDeactivated:
|
||||
p.State = int32(model.PROJECTSTATE_INACTIVE)
|
||||
|
@@ -61,6 +61,8 @@ func (key ProjectGrantSearchKey) ToColumnName() string {
|
||||
return ProjectGrantKeyProjectID
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER:
|
||||
return ProjectGrantKeyResourceOwner
|
||||
case proj_model.GRANTEDPROJECTSEARCHKEY_ROLE_KEYS:
|
||||
return ProjectGrantKeyRoleKeys
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
Reference in New Issue
Block a user