mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-14 01:45:12 +00:00
fix: add project id on project grant (#202)
* fix: add project id on project grant * fix: get granted project grant member
This commit is contained in:
@@ -62,6 +62,14 @@ func (repo *ProjectRepo) SearchGrantedProjects(ctx context.Context, request *pro
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *ProjectRepo) GetGrantedProjectGrantByIDs(ctx context.Context, projectID, grantID string) (project *proj_model.GrantedProjectView, err error) {
|
||||||
|
p, err := repo.View.GrantedProjectGrantByIDs(projectID, grantID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model.GrantedProjectToModel(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (member *proj_model.ProjectMember, err error) {
|
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (member *proj_model.ProjectMember, err error) {
|
||||||
member = proj_model.NewProjectMember(projectID, userID)
|
member = proj_model.NewProjectMember(projectID, userID)
|
||||||
return repo.ProjectEvents.ProjectMemberByIDs(ctx, member)
|
return repo.ProjectEvents.ProjectMemberByIDs(ctx, member)
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ func (v *View) GrantedProjectByIDs(projectID, orgID string) (*model.GrantedProje
|
|||||||
return view.GrantedProjectByIDs(v.Db, grantedProjectTable, projectID, orgID)
|
return view.GrantedProjectByIDs(v.Db, grantedProjectTable, projectID, orgID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *View) GrantedProjectGrantByIDs(projectID, grantID string) (*model.GrantedProjectView, error) {
|
||||||
|
return view.GrantedProjectGrantByIDs(v.Db, grantedProjectTable, projectID, grantID)
|
||||||
|
}
|
||||||
|
|
||||||
func (v *View) GrantedProjectsByID(projectID string) ([]*model.GrantedProjectView, error) {
|
func (v *View) GrantedProjectsByID(projectID string) ([]*model.GrantedProjectView, error) {
|
||||||
return view.GrantedProjectsByID(v.Db, grantedProjectTable, projectID)
|
return view.GrantedProjectsByID(v.Db, grantedProjectTable, projectID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type ProjectRepository interface {
|
|||||||
DeactivateProject(ctx context.Context, id string) (*model.Project, error)
|
DeactivateProject(ctx context.Context, id string) (*model.Project, error)
|
||||||
ReactivateProject(ctx context.Context, id string) (*model.Project, error)
|
ReactivateProject(ctx context.Context, id string) (*model.Project, error)
|
||||||
SearchGrantedProjects(ctx context.Context, request *model.GrantedProjectSearchRequest) (*model.GrantedProjectSearchResponse, error)
|
SearchGrantedProjects(ctx context.Context, request *model.GrantedProjectSearchRequest) (*model.GrantedProjectSearchResponse, error)
|
||||||
|
GetGrantedProjectGrantByIDs(ctx context.Context, projectID, grantID string) (*model.GrantedProjectView, error)
|
||||||
|
|
||||||
ProjectMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectMember, error)
|
ProjectMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectMember, error)
|
||||||
AddProjectMember(ctx context.Context, member *model.ProjectMember) (*model.ProjectMember, error)
|
AddProjectMember(ctx context.Context, member *model.ProjectMember) (*model.ProjectMember, error)
|
||||||
|
|||||||
@@ -12,12 +12,21 @@ func GrantedProjectByIDs(db *gorm.DB, table, projectID, orgID string) (*model.Gr
|
|||||||
project := new(model.GrantedProjectView)
|
project := new(model.GrantedProjectView)
|
||||||
|
|
||||||
projectIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
projectIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
grantIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
orgIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_ORGID, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery)
|
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||||
err := query(db, project)
|
err := query(db, project)
|
||||||
return project, err
|
return project, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GrantedProjectGrantByIDs(db *gorm.DB, table, projectID, grantID string) (*model.GrantedProjectView, error) {
|
||||||
|
project := new(model.GrantedProjectView)
|
||||||
|
|
||||||
|
projectIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_PROJECTID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
grantIDQuery := model.GrantedProjectSearchQuery{Key: proj_model.GRANTEDPROJECTSEARCHKEY_GRANTID, Value: grantID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||||
|
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery)
|
||||||
|
err := query(db, project)
|
||||||
|
return project, err
|
||||||
|
}
|
||||||
func GrantedProjectsByID(db *gorm.DB, table, projectID string) ([]*model.GrantedProjectView, error) {
|
func GrantedProjectsByID(db *gorm.DB, table, projectID string) ([]*model.GrantedProjectView, error) {
|
||||||
projects := make([]*model.GrantedProjectView, 0)
|
projects := make([]*model.GrantedProjectView, 0)
|
||||||
queries := []*proj_model.GrantedProjectSearchQuery{
|
queries := []*proj_model.GrantedProjectSearchQuery{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -167,7 +167,7 @@
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1ProjectGrant"
|
"$ref": "#/definitions/v1GrantedProject"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, erro
|
|||||||
return projectFromModel(project), nil
|
return projectFromModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetGrantedProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*ProjectGrant, error) {
|
func (s *Server) GetGrantedProjectGrantByID(ctx context.Context, in *ProjectGrantID) (*GrantedProject, error) {
|
||||||
project, err := s.project.ProjectGrantByID(ctx, in.ProjectId, in.Id)
|
project, err := s.project.GetGrantedProjectGrantByIDs(ctx, in.ProjectId, in.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return projectGrantFromModel(project), nil
|
return grantedProjectFromModel(project), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) AddProjectRole(ctx context.Context, in *ProjectRoleAdd) (*ProjectRole, error) {
|
func (s *Server) AddProjectRole(ctx context.Context, in *ProjectRoleAdd) (*ProjectRole, error) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ func projectGrantFromModel(grant *proj_model.ProjectGrant) *ProjectGrant {
|
|||||||
GrantedOrgId: grant.GrantedOrgID,
|
GrantedOrgId: grant.GrantedOrgID,
|
||||||
RoleKeys: grant.RoleKeys,
|
RoleKeys: grant.RoleKeys,
|
||||||
Sequence: grant.Sequence,
|
Sequence: grant.Sequence,
|
||||||
|
ProjectId: grant.AggregateID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ service ManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GRANTED_PROJECT_GRANTS
|
//GRANTED_PROJECT_GRANTS
|
||||||
rpc GetGrantedProjectGrantByID(ProjectGrantID) returns (ProjectGrant) {
|
rpc GetGrantedProjectGrantByID(ProjectGrantID) returns (GrantedProject) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
get: "/grantedprojects/{project_id}/grants/{id}"
|
get: "/grantedprojects/{project_id}/grants/{id}"
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user