mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 14:52:35 +00:00
fix(project): include an option to add project members during project creation (#10654)
# Which Problems Are Solved When a project is created by a user with only the `PROJECT_CREATOR` role, they can no longer view/manage the created project. Although the project is created, the user sees the following error: `No matching permissions found (AUTH-3jknH)`. This is due to the [removal](https://github.com/zitadel/zitadel/pull/9317) of auto-assignment of the `PROJECT_OWNER` role when a project is newly created. # How the Problems Are Solved By introducing optional fields in the CreateProject API to include a list of users and a list of project member roles to be assigned to the users. When there are no roles mentioned, the `PROJECT_OWNER` role is assigned by default to all the users mentioned in the list. # Additional Changes N/A # Additional Context - Closes #10561 - Closes #10592 - Should be backported as this issue is not specific to v4 --------- Co-authored-by: conblem <mail@conblem.me> Co-authored-by: Stefan Benz <46600784+stebenz@users.noreply.github.com> Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func ProjectCreateToCommand(req *mgmt_pb.AddProjectRequest, projectID string, resourceOwner string) *command.AddProject {
|
||||
admins := projectCreateAdminsToCommand(req.GetAdmins())
|
||||
return &command.AddProject{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: projectID,
|
||||
@@ -28,6 +29,7 @@ func ProjectCreateToCommand(req *mgmt_pb.AddProjectRequest, projectID string, re
|
||||
ProjectRoleCheck: req.ProjectRoleCheck,
|
||||
HasProjectCheck: req.HasProjectCheck,
|
||||
PrivateLabelingSetting: privateLabelingSettingToDomain(req.PrivateLabelingSetting),
|
||||
Admins: admins,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +58,20 @@ func privateLabelingSettingToDomain(setting proj_pb.PrivateLabelingSetting) doma
|
||||
}
|
||||
}
|
||||
|
||||
func projectCreateAdminsToCommand(requestAdmins []*mgmt_pb.AddProjectRequest_Admin) []*command.AddProjectAdmin {
|
||||
if len(requestAdmins) == 0 {
|
||||
return nil
|
||||
}
|
||||
admins := make([]*command.AddProjectAdmin, len(requestAdmins))
|
||||
for i, admin := range requestAdmins {
|
||||
admins[i] = &command.AddProjectAdmin{
|
||||
ID: admin.GetUserId(),
|
||||
Roles: admin.GetRoles(),
|
||||
}
|
||||
}
|
||||
return admins
|
||||
}
|
||||
|
||||
func AddProjectRoleRequestToCommand(req *mgmt_pb.AddProjectRoleRequest, resourceOwner string) *command.AddProjectRole {
|
||||
return &command.AddProjectRole{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
|
||||
Reference in New Issue
Block a user