From d2a93af9bf4be024096287a653ddab6664e01106 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Fri, 8 Aug 2025 18:22:58 +0200 Subject: [PATCH] fix(events): user auth names Signed-off-by: Miguel Martinez --- .../pkg/auditor/events/testdata/users/user_logs_in.json | 2 +- .../pkg/auditor/events/testdata/users/user_signs_up.json | 2 +- app/controlplane/pkg/auditor/events/user.go | 4 ++-- app/controlplane/pkg/biz/user.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controlplane/pkg/auditor/events/testdata/users/user_logs_in.json b/app/controlplane/pkg/auditor/events/testdata/users/user_logs_in.json index c055dc988..817657661 100644 --- a/app/controlplane/pkg/auditor/events/testdata/users/user_logs_in.json +++ b/app/controlplane/pkg/auditor/events/testdata/users/user_logs_in.json @@ -7,7 +7,7 @@ "ActorEmail": "john@cyberdyne.io", "ActorName": "John Connor", "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", - "Description": "john@cyberdyne.io has logged in", + "Description": "John Connor has logged in", "Info": { "user_id": "1089bb36-e27b-428b-8009-d015c8737c54", "email": "john@cyberdyne.io", diff --git a/app/controlplane/pkg/auditor/events/testdata/users/user_signs_up.json b/app/controlplane/pkg/auditor/events/testdata/users/user_signs_up.json index 5ccb206ee..85e9fed61 100644 --- a/app/controlplane/pkg/auditor/events/testdata/users/user_signs_up.json +++ b/app/controlplane/pkg/auditor/events/testdata/users/user_signs_up.json @@ -7,7 +7,7 @@ "ActorEmail": "john@cyberdyne.io", "ActorName": "John Connor", "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", - "Description": "john@cyberdyne.io has signed up", + "Description": "John Connor has signed up", "Info": { "user_id": "1089bb36-e27b-428b-8009-d015c8737c54", "email": "john@cyberdyne.io" diff --git a/app/controlplane/pkg/auditor/events/user.go b/app/controlplane/pkg/auditor/events/user.go index 235a9172b..fc892e3b2 100644 --- a/app/controlplane/pkg/auditor/events/user.go +++ b/app/controlplane/pkg/auditor/events/user.go @@ -73,7 +73,7 @@ func (p *UserSignedUp) ActionType() string { } func (p *UserSignedUp) Description() string { - return fmt.Sprintf("%s has signed up", p.Email) + return fmt.Sprintf("%s has signed up", auditor.GetActorIdentifier()) } type UserLoggedIn struct { @@ -87,7 +87,7 @@ func (p *UserLoggedIn) ActionType() string { } func (p *UserLoggedIn) Description() string { - return fmt.Sprintf("%s has logged in", p.Email) + return fmt.Sprintf("%s has logged in", auditor.GetActorIdentifier()) } func (p *UserLoggedIn) ActionInfo() (json.RawMessage, error) { diff --git a/app/controlplane/pkg/biz/user.go b/app/controlplane/pkg/biz/user.go index 883122506..def14691b 100644 --- a/app/controlplane/pkg/biz/user.go +++ b/app/controlplane/pkg/biz/user.go @@ -145,7 +145,7 @@ func (uc *UserUseCase) UpsertByEmail(ctx context.Context, email string, opts *Up } // set the context user so it can be used in the auditor - ctx = entities.WithCurrentUser(ctx, &entities.User{Email: u.Email, ID: u.ID}) + ctx = entities.WithCurrentUser(ctx, &entities.User{Email: u.Email, ID: u.ID, FirstName: u.FirstName, LastName: u.LastName}) uc.auditorUC.Dispatch(ctx, &events.UserSignedUp{ UserBase: &events.UserBase{ UserID: ToPtr(uuid.MustParse(u.ID)), @@ -155,7 +155,7 @@ func (uc *UserUseCase) UpsertByEmail(ctx context.Context, email string, opts *Up }, nil) } else { // Login case - ctx = entities.WithCurrentUser(ctx, &entities.User{Email: u.Email, ID: u.ID}) + ctx = entities.WithCurrentUser(ctx, &entities.User{Email: u.Email, ID: u.ID, FirstName: u.FirstName, LastName: u.LastName}) uc.auditorUC.Dispatch(ctx, &events.UserLoggedIn{ UserBase: &events.UserBase{ UserID: ToPtr(uuid.MustParse(u.ID)),