Skip to content

Commit b5480e9

Browse files
committed
include user info on OrgUserJoined event
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
1 parent 718071d commit b5480e9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

app/controlplane/pkg/auditor/events/organization.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (p *OrgBase) TargetID() *uuid.UUID {
5757

5858
func (p *OrgBase) ActionInfo() (json.RawMessage, error) {
5959
if p.OrgName == "" || p.OrgID == nil {
60-
return nil, errors.New("user id and org name are required")
60+
return nil, errors.New("org name and org id are required")
6161
}
6262

6363
return json.Marshal(&p)
@@ -79,6 +79,10 @@ func (p *OrgCreated) Description() string {
7979
// user joined the organization
8080
type OrgUserJoined struct {
8181
*OrgBase
82+
// UserID of the user that joined the organization
83+
UserID uuid.UUID `json:"user_id,omitempty"`
84+
// UserEmail of the user that joined the organization
85+
UserEmail string `json:"user_email,omitempty"`
8286
}
8387

8488
func (p *OrgUserJoined) ActionType() string {
@@ -89,6 +93,14 @@ func (p *OrgUserJoined) Description() string {
8993
return fmt.Sprintf("{{ .ActorEmail }} has joined the organization %s", p.OrgName)
9094
}
9195

96+
func (p *OrgUserJoined) ActionInfo() (json.RawMessage, error) {
97+
if p.OrgName == "" || p.OrgID == nil || p.UserID == uuid.Nil || p.UserEmail == "" {
98+
return nil, errors.New("org name, org id, user id and user email are required")
99+
}
100+
101+
return json.Marshal(&p)
102+
}
103+
92104
// user left the organization
93105
type OrgUserLeft struct {
94106
*OrgBase

app/controlplane/pkg/biz/orginvitation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ func (uc *OrgInvitationUseCase) AcceptPendingInvitations(ctx context.Context, re
287287
OrgID: &orgUUID,
288288
OrgName: invitation.Org.Name,
289289
},
290+
UserID: userUUID,
291+
UserEmail: user.Email,
290292
}, &orgUUID)
291293
}
292294

0 commit comments

Comments
 (0)