primeros cambios hechos para tener el multitenant

This commit is contained in:
fede committed 2026-11-10 17:06:56 -03:00
1 parent 34ad4424f9
commit 4e082e8767
132 files changed
+6202 -762

No files matched your search

-2
View File
@@ -8,8 +8,6 @@ import (
"github.com/gin-gonic/gin"
)
const ContextPermissionsKey = "permissions"
// PermisosDeUsuario aplana la jerarquia completa de grupos y subgrupos en una
// lista de IDs de permisos sin duplicados.
func PermisosDeUsuario(usuario *models_seguridad.Usuario) []uint {
+47
View File
@@ -0,0 +1,47 @@
package utils
import (
"github.com/gin-gonic/gin"
)
const (
ContextPermissionsKey = "permissions"
ContextEmpresaIDKey = "empresaID"
ContextEmpresaRolKey = "empresaRol"
ContextPlataformaAdmin = "esPlataformaAdmin"
)
// EmpresaID devuelve la empresa activa que dejo el middleware de auth.
func EmpresaID(c *gin.Context) uint {
value, ok := c.Get(ContextEmpresaIDKey)
if !ok {
return 0
}
id, _ := value.(uint)
return id
}
// SetEmpresaID guarda la empresa activa en el contexto de Gin.
func SetEmpresaID(c *gin.Context, id uint) {
c.Set(ContextEmpresaIDKey, id)
}
// EmpresaRol devuelve el rol del usuario dentro de la empresa activa.
func EmpresaRol(c *gin.Context) string {
value, ok := c.Get(ContextEmpresaRolKey)
if !ok {
return ""
}
rol, _ := value.(string)
return rol
}
// EsPlataformaAdmin indica si el usuario tiene un rol de plataforma.
func EsPlataformaAdmin(c *gin.Context) bool {
value, ok := c.Get(ContextPlataformaAdmin)
if !ok {
return false
}
es, _ := value.(bool)
return es
}