Mohammed Nafees 3 лет назад
Родитель
Сommit
8ed3ce2342

+ 1 - 1
api/types/invite.go

@@ -11,7 +11,7 @@ type Invite struct {
 	Email    string   `json:"email"`
 	Accepted bool     `json:"accepted"`
 	Kind     string   `json:"kind"`
-	RoleUIDs []string `json:"roles"`
+	Roles    []string `json:"roles"`
 }
 
 type GetInviteResponse Invite

+ 2 - 2
ee/api/server/handlers/invite/accept.go

@@ -81,8 +81,8 @@ func (c *InviteAcceptHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 
 	inviteType := invite.ToInviteType()
 
-	if len(inviteType.RoleUIDs) > 0 {
-		for _, roleUID := range inviteType.RoleUIDs {
+	if len(inviteType.Roles) > 0 {
+		for _, roleUID := range inviteType.Roles {
 			err := updateProjectRoleWithUser(c.Repo(), proj.ID, user.ID, roleUID)
 
 			if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {

+ 1 - 1
ee/api/server/handlers/invite/create.go

@@ -107,6 +107,6 @@ func CreateInviteWithProject(invite *types.CreateInviteRequest, projectID uint)
 		Expiry:    &expiry,
 		ProjectID: projectID,
 		Token:     oauth.CreateRandomState(),
-		RoleUIDs:  []byte(strings.Join(invite.RoleUIDs, ",")),
+		Roles:     []byte(strings.Join(invite.RoleUIDs, ",")),
 	}, nil
 }

+ 1 - 1
ee/api/server/handlers/invite/update_role.go

@@ -54,7 +54,7 @@ func (c *InviteUpdateRoleHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
 			}
 		}
 
-		invite.RoleUIDs = []byte(strings.Join(request.RoleUIDs, ","))
+		invite.Roles = []byte(strings.Join(request.RoleUIDs, ","))
 
 		changed = true
 	} else if invite.Kind != "" { // legacy invite

+ 2 - 2
internal/models/invite.go

@@ -22,7 +22,7 @@ type Invite struct {
 
 	ProjectID uint
 	UserID    uint
-	RoleUIDs  []byte // stored as a byte-array of comma-separated strings of role UIDs
+	Roles     []byte // stored as a byte-array of comma-separated strings of role UIDs
 }
 
 // ToInviteType generates an external Invite to be shared over REST
@@ -34,7 +34,7 @@ func (i *Invite) ToInviteType() *types.Invite {
 		Expired:  i.IsExpired(),
 		Accepted: i.IsAccepted(),
 		Kind:     i.Kind,
-		RoleUIDs: strings.Split(string(i.RoleUIDs), ""),
+		Roles:    strings.Split(string(i.Roles), ","),
 	}
 }