Skip to content

Commit e01be0d

Browse files
authored
fix: log auth actions (#479)
1 parent e22cbc7 commit e01be0d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/audit_log_entry.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/gofrs/uuid"
99
"github.com/netlify/gotrue/storage"
1010
"github.com/pkg/errors"
11+
"github.com/sirupsen/logrus"
1112
)
1213

1314
type AuditAction string
@@ -96,7 +97,12 @@ func NewAuditLogEntry(tx *storage.Connection, instanceID uuid.UUID, actor *User,
9697
l.Payload["traits"] = traits
9798
}
9899

99-
return errors.Wrap(tx.Create(&l), "Database error creating audit log entry")
100+
if err := tx.Create(&l); err != nil {
101+
return errors.Wrap(err, "Database error creating audit log entry")
102+
}
103+
104+
logrus.Infof("{\"actor_id\": %v, \"action\": %v, \"timestamp\": %v, \"log_type\": %v}", actor.ID, action, l.Payload["timestamp"], actionLogTypeMap[action])
105+
return nil
100106
}
101107

102108
func FindAuditLogEntries(tx *storage.Connection, instanceID uuid.UUID, filterColumns []string, filterValue string, pageParams *Pagination) ([]*AuditLogEntry, error) {

0 commit comments

Comments
 (0)