feat: add is admin
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package users
|
||||
|
||||
type UserInfo struct {
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
Balance int64 `json:"balance"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user