feat: add is admin
This commit is contained in:
Binary file not shown.
0
backend/__debug_bin746813113
Normal file
0
backend/__debug_bin746813113
Normal file
@@ -5,6 +5,7 @@ import (
|
|||||||
"backend/providers/jwt"
|
"backend/providers/jwt"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
hashids "github.com/speps/go-hashids/v2"
|
hashids "github.com/speps/go-hashids/v2"
|
||||||
)
|
)
|
||||||
@@ -47,5 +48,11 @@ func (c *Controller) Info(ctx fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
info.Balance = balance
|
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)
|
return ctx.JSON(info)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package users
|
package users
|
||||||
|
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
|
IsAdmin bool `json:"is_admin"`
|
||||||
Balance int64 `json:"balance"`
|
Balance int64 `json:"balance"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user