mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
710652ef24
* 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
73 lines
2.4 KiB
Go
73 lines
2.4 KiB
Go
package view
|
|
|
|
import (
|
|
grant_model "github.com/caos/zitadel/internal/usergrant/model"
|
|
"github.com/caos/zitadel/internal/usergrant/repository/view"
|
|
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
|
|
global_view "github.com/caos/zitadel/internal/view"
|
|
)
|
|
|
|
const (
|
|
userGrantTable = "management.user_grants"
|
|
)
|
|
|
|
func (v *View) UserGrantByID(grantID string) (*model.UserGrantView, error) {
|
|
return view.UserGrantByID(v.Db, userGrantTable, grantID)
|
|
}
|
|
|
|
func (v *View) SearchUserGrants(request *grant_model.UserGrantSearchRequest) ([]*model.UserGrantView, int, error) {
|
|
return view.SearchUserGrants(v.Db, userGrantTable, request)
|
|
}
|
|
|
|
func (v *View) UserGrantsByUserID(userID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByUserID(v.Db, userGrantTable, userID)
|
|
}
|
|
|
|
func (v *View) UserGrantsByProjectID(projectID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByProjectID(v.Db, userGrantTable, projectID)
|
|
}
|
|
|
|
func (v *View) UserGrantsByOrgID(orgID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByOrgID(v.Db, userGrantTable, orgID)
|
|
}
|
|
|
|
func (v *View) UserGrantsByProjectIDAndRoleKey(projectID, roleKey string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByProjectIDAndRole(v.Db, userGrantTable, projectID, roleKey)
|
|
}
|
|
|
|
func (v *View) UserGrantsByOrgIDAndProjectID(orgID, projectID string) ([]*model.UserGrantView, error) {
|
|
return view.UserGrantsByOrgIDAndProjectID(v.Db, userGrantTable, orgID, projectID)
|
|
}
|
|
|
|
func (v *View) PutUserGrant(grant *model.UserGrantView, sequence uint64) error {
|
|
err := view.PutUserGrant(v.Db, userGrantTable, grant)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedUserGrantSequence(sequence)
|
|
}
|
|
|
|
func (v *View) DeleteUserGrant(grantID string, eventSequence uint64) error {
|
|
err := view.DeleteUserGrant(v.Db, userGrantTable, grantID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserGrantSequence(eventSequence)
|
|
}
|
|
|
|
func (v *View) GetLatestUserGrantSequence() (uint64, error) {
|
|
return v.latestSequence(userGrantTable)
|
|
}
|
|
|
|
func (v *View) ProcessedUserGrantSequence(eventSequence uint64) error {
|
|
return v.saveCurrentSequence(userGrantTable, eventSequence)
|
|
}
|
|
|
|
func (v *View) GetLatestUserGrantFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
return v.latestFailedEvent(userGrantTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedUserGrantFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|