feat: add is admin

This commit is contained in:
Rogee
2024-12-12 19:29:02 +08:00
parent 8a1477e991
commit 38a45958bd
4 changed files with 8 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"backend/providers/jwt"
"github.com/gofiber/fiber/v3"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
hashids "github.com/speps/go-hashids/v2"
)
@@ -47,5 +48,11 @@ func (c *Controller) Info(ctx fiber.Ctx) error {
}
info.Balance = balance
tenant, err := c.svc.GetTenantByID(ctx.Context(), claim.TenantID)
if err != nil {
return errors.Wrapf(err, "get tenant: %d", claim.TenantID)
}
info.IsAdmin = tenant.BindUserID == claim.UserID
return ctx.JSON(info)
}

View File

@@ -1,5 +1,6 @@
package users
type UserInfo struct {
IsAdmin bool `json:"is_admin"`
Balance int64 `json:"balance"`
}