diff --git a/auth/api_grp.go b/auth/api_grp.go index 837c6c7..61ed041 100644 --- a/auth/api_grp.go +++ b/auth/api_grp.go @@ -48,8 +48,9 @@ func ApiGrpNew(c *gin.Context) { panic(err) } history.Send(history.Info().Nm("Create"). - Bd(data).Grp(data.Name). - Iss(c.GetString(GinUserKey))) + Bd(data).Grp(data.Name).Scp("grp"). + Iss(c.GetString(GinUserKey)). + Msgf("Create group %v", data.Name)) server.Res(c, &server.Response{Data: grp}) } @@ -88,6 +89,10 @@ func ApiGrpUpdate(c *gin.Context) { if fetch != "" { DB.Preload("Users").First(grp, data.ID) } + history.Send(history.Info().Nm("Update"). + Bd(data).Grp(data.Name).Scp("grp"). + Iss(c.GetString(GinUserKey)). + Msgf("Update group %v", data.Name)) server.Res(c, &server.Response{Data: grp}) } @@ -118,6 +123,10 @@ func ApiGrpDel(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Delete"). + Bd(grp).Grp(grp.Name).Scp("grp"). + Iss(c.GetString(GinUserKey)). + Msgf("Delete group %v", grp.Name)) server.Res(c, &server.Response{Data: "ok"}) } @@ -155,6 +164,10 @@ func ApiGrpAssign(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Assign"). + Bd(map[string]string{"user": usr.Username, "group": grp.Name}). + Grp(grp.Name).Iss(c.GetString(GinUserKey)).Scp("grp"). + Msgf("Assigned %v to group %v", usr.Username, grp.Name)) server.Res(c, &server.Response{Data: "ok"}) } @@ -188,5 +201,9 @@ func ApiGrpRemove(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Remove"). + Bd(map[string]string{"user": usr.Username, "group": grp.Name}). + Grp(grp.Name).Iss(c.GetString(GinUserKey)).Scp("grp"). + Msgf("Remove %v from group %v", usr.Username, grp.Name)) server.Res(c, &server.Response{Data: "ok"}) } diff --git a/auth/api_user.go b/auth/api_user.go index 4deadd9..bf24575 100644 --- a/auth/api_user.go +++ b/auth/api_user.go @@ -6,6 +6,7 @@ import ( "github.com/gin-gonic/gin" "gorm.io/gorm" "kumoly.io/kumoly/app/errors" + "kumoly.io/kumoly/app/history" "kumoly.io/kumoly/app/server" ) @@ -40,6 +41,10 @@ func ApiUserNew(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Create"). + Grp(data.Name).Scp("usr"). + Iss(c.GetString(GinUserKey)). + Msgf("Create user %v", data.Name)) server.Res(c, &server.Response{Data: usr}) } @@ -106,6 +111,10 @@ func ApiUserDelete(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Delete"). + Grp(usr.Username).Scp("usr"). + Iss(c.GetString(GinUserKey)). + Msgf("Delete user %v", usr.Username)) server.Res(c, &server.Response{Data: "ok"}) } @@ -149,6 +158,10 @@ func ApiUserChangePasswd(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("ChangePassword"). + Grp(usr.Username).Scp("usr"). + Iss(c.GetString(GinUserKey)). + Msgf("User %v password changed", usr.Username)) server.Res(c, &server.Response{Data: "ok"}) } @@ -166,6 +179,10 @@ func ApiUserActivate(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Activate"). + Grp(usr.Username).Scp("usr"). + Iss(c.GetString(GinUserKey)). + Msgf("User %v activated", usr.Username)) server.Res(c, &server.Response{Data: "ok"}) } @@ -186,5 +203,9 @@ func ApiUserDeactivate(c *gin.Context) { if err != nil { panic(err) } + history.Send(history.Info().Nm("Deactivate"). + Grp(usr.Username).Scp("usr"). + Iss(c.GetString(GinUserKey)). + Msgf("User %v deactivated", usr.Username)) server.Res(c, &server.Response{Data: "ok"}) }