diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index df38cf5..9166abe 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,11 @@
-
+
-
-
+
+
+
@@ -154,7 +155,6 @@
-
@@ -179,7 +179,8 @@
-
+
+
true
diff --git a/pkg/internal/server/api/accounts_api.go b/pkg/internal/server/api/accounts_api.go
index b5b3281..152afe9 100644
--- a/pkg/internal/server/api/accounts_api.go
+++ b/pkg/internal/server/api/accounts_api.go
@@ -43,6 +43,8 @@ func getUserinfo(c *fiber.Ctx) error {
Preload("Badges").
First(&data).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
+ } else {
+ data.PermNodes = c.Locals("permissions").(map[string]any)
}
var resp fiber.Map
diff --git a/pkg/internal/server/api/userinfo_api.go b/pkg/internal/server/api/userinfo_api.go
index b200d8e..d1196e4 100644
--- a/pkg/internal/server/api/userinfo_api.go
+++ b/pkg/internal/server/api/userinfo_api.go
@@ -1,8 +1,10 @@
package api
import (
+ "fmt"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
+ "git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
@@ -19,5 +21,17 @@ func getOtherUserinfo(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
}
+ groups, err := services.GetUserAccountGroup(account)
+ if err != nil {
+ return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to get account groups: %v", err))
+ }
+ for _, group := range groups {
+ for k, v := range group.PermNodes {
+ if _, ok := account.PermNodes[k]; !ok {
+ account.PermNodes[k] = v
+ }
+ }
+ }
+
return c.JSON(account)
}
diff --git a/pkg/internal/services/account_groups.go b/pkg/internal/services/account_groups.go
index 8c68a50..b3ff402 100644
--- a/pkg/internal/services/account_groups.go
+++ b/pkg/internal/services/account_groups.go
@@ -15,8 +15,8 @@ func GetUserAccountGroup(user models.Account) ([]models.AccountGroup, error) {
}
var groups []models.AccountGroup
- if err := database.C.Where("id IN ?", lo.Map(groups, func(item models.AccountGroup, index int) uint {
- return item.ID
+ if err := database.C.Where("id IN ?", lo.Map(members, func(item models.AccountGroupMember, index int) uint {
+ return item.GroupID
})).Find(&groups).Error; err != nil {
return nil, err
}