fix(tenant): 封堵审计文件与历史用户跨站访问
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
@@ -16,6 +17,7 @@ type Meta struct {
|
||||
}
|
||||
|
||||
type Entry struct {
|
||||
TenantID uint64
|
||||
ActorType string
|
||||
ActorID uint64
|
||||
Action string
|
||||
@@ -31,7 +33,12 @@ func Append(tx *gorm.DB, entry Entry) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tenantID := entry.TenantID
|
||||
if tenantID == 0 && tx.Statement != nil && tx.Statement.Context != nil {
|
||||
tenantID = tenancy.IDFromContext(tx.Statement.Context)
|
||||
}
|
||||
row := model.AuditLog{
|
||||
TenantID: tenantID,
|
||||
ActorType: entry.ActorType,
|
||||
ActorID: entry.ActorID,
|
||||
Action: entry.Action,
|
||||
|
||||
Reference in New Issue
Block a user