⏪ Revert "♻️ Move models.Account to sec.UserInfo" for a better solution
This reverts commit 8fbb7960
This commit is contained in:
@ -5,7 +5,6 @@ import (
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
@ -28,13 +27,13 @@ func notifyAllUser(c *fiber.Ctx) error {
|
||||
if err := exts.EnsureGrantedPerm(c, "AdminNotifyAll", true); err != nil {
|
||||
return err
|
||||
}
|
||||
operator := c.Locals("user").(*sec.UserInfo)
|
||||
operator := c.Locals("user").(models.Account)
|
||||
|
||||
var users []models.Account
|
||||
if err := database.C.Find(&users).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
} else {
|
||||
services.AddAuditRecord(operator.ID, "notify.all", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
services.AddAuditRecord(operator, "notify.all", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
"payload": data,
|
||||
})
|
||||
}
|
||||
@ -86,13 +85,13 @@ func notifyOneUser(c *fiber.Ctx) error {
|
||||
if err := exts.EnsureGrantedPerm(c, "AdminNotifyAll", true); err != nil {
|
||||
return err
|
||||
}
|
||||
operator := c.Locals("user").(*sec.UserInfo)
|
||||
operator := c.Locals("user").(models.Account)
|
||||
|
||||
var user models.Account
|
||||
if err := database.C.Where("id = ?", data.UserID).First(&user).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
} else {
|
||||
services.AddAuditRecord(operator.ID, "notify.one", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
services.AddAuditRecord(operator, "notify.one", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
"user_id": user.ID,
|
||||
"payload": data,
|
||||
})
|
||||
|
@ -2,11 +2,10 @@ package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@ -17,7 +16,7 @@ func editUserPermission(c *fiber.Ctx) error {
|
||||
if err := exts.EnsureGrantedPerm(c, "AdminUserPermission", true); err != nil {
|
||||
return err
|
||||
}
|
||||
operator := c.Locals("user").(*sec.UserInfo)
|
||||
operator := c.Locals("user").(models.Account)
|
||||
|
||||
var data struct {
|
||||
PermNodes map[string]any `json:"perm_nodes" validate:"required"`
|
||||
@ -40,7 +39,7 @@ func editUserPermission(c *fiber.Ctx) error {
|
||||
if err := database.C.Save(&user).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
} else {
|
||||
services.AddAuditRecord(operator.ID, "user.permissions.edit", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
services.AddAuditRecord(operator, "user.permissions.edit", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
"user_id": user.ID,
|
||||
"previous_permissions": prev,
|
||||
"new_permissions": data.PermNodes,
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@ -54,7 +53,7 @@ func forceConfirmAccount(c *fiber.Ctx) error {
|
||||
if err := exts.EnsureGrantedPerm(c, "AdminUserConfirmation", true); err != nil {
|
||||
return err
|
||||
}
|
||||
operator := c.Locals("user").(*sec.UserInfo)
|
||||
operator := c.Locals("user").(models.Account)
|
||||
|
||||
var user models.Account
|
||||
if err := database.C.Where("id = ?", userId).First(&user).Error; err != nil {
|
||||
@ -64,7 +63,7 @@ func forceConfirmAccount(c *fiber.Ctx) error {
|
||||
if err := services.ForceConfirmAccount(user); err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
} else {
|
||||
services.AddAuditRecord(operator.ID, "user.confirm", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
services.AddAuditRecord(operator, "user.confirm", c.IP(), c.Get(fiber.HeaderUserAgent), map[string]any{
|
||||
"user_id": user.ID,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user