Private
Public Access
primeros cambios hechos para tener el multitenant
This commit is contained in:
1 parent
34ad4424f9
commit
4e082e8767
132 files changed
+6202
-762
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user