feat: specify org member roles in org setup (#3950)

This commit is contained in:
Livio Spring 2022-07-12 15:38:47 +02:00 committed by GitHub
parent 68f0114671
commit fa4bc47b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View File

@ -3642,6 +3642,7 @@ this is en empty request
| ----- | ---- | ----------- | ----------- |
| org | SetUpOrgRequest.Org | - | message.required: true<br /> |
| [**oneof**](https://developers.google.com/protocol-buffers/docs/proto3#oneof) user.human | SetUpOrgRequest.Human | oneof field for the user managing the organisation | |
| roles | repeated string | specify Org Member Roles for the provided user (default is ORG_OWNER if roles are empty) | |

View File

@ -66,6 +66,7 @@ func (s *Server) SetUpOrg(ctx context.Context, req *admin_pb.SetUpOrgRequest) (*
Name: req.Org.Name,
CustomDomain: req.Org.Domain,
Human: human,
Roles: req.Roles,
}, userIDs...)
if err != nil {
return nil, err

View File

@ -19,6 +19,7 @@ type OrgSetup struct {
Name string
CustomDomain string
Human AddHuman
Roles []string
}
func (c *Commands) SetUpOrg(ctx context.Context, o *OrgSetup, userIDs ...string) (string, *domain.ObjectDetails, error) {
@ -35,10 +36,15 @@ func (c *Commands) SetUpOrg(ctx context.Context, o *OrgSetup, userIDs ...string)
orgAgg := org.NewAggregate(orgID)
userAgg := user_repo.NewAggregate(userID, orgID)
roles := []string{domain.RoleOrgOwner}
if len(o.Roles) > 0 {
roles = o.Roles
}
validations := []preparation.Validation{
AddOrgCommand(ctx, orgAgg, o.Name, userIDs...),
AddHumanCommand(userAgg, &o.Human, c.userPasswordAlg, c.userEncryption),
c.AddOrgMemberCommand(orgAgg, userID, domain.RoleOrgOwner),
c.AddOrgMemberCommand(orgAgg, userID, roles...),
}
if o.CustomDomain != "" {
validations = append(validations, AddOrgDomain(orgAgg, o.CustomDomain))

View File

@ -3099,6 +3099,8 @@ message SetUpOrgRequest {
// oneof field for the user managing the organisation
Human human = 2;
}
// specify Org Member Roles for the provided user (default is ORG_OWNER if roles are empty)
repeated string roles = 3;
}
message SetUpOrgResponse {