Bloquear acceso a empersa por url cuando no se es administrador

This commit is contained in:
Oscar Irigoyen
2022-09-30 09:42:56 -07:00
parent 093d1e5ae9
commit bbe0ea663c

View File

@@ -6,6 +6,7 @@ Imports Extensiones
Imports System.Runtime.InteropServices
Imports System.IO
Imports Microsoft.Reporting.WebForms
Imports Microsoft.Owin.Security.Provider
Partial Class Sistemas_Empresa
Inherits ClsPaginas
@@ -152,6 +153,18 @@ Partial Class Sistemas_Empresa
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If UsuarioActual.CveRol <> 1 AndAlso (Request("CveEmpresa") IsNot Nothing AndAlso Request("CveEmpresa").ToEntero > 0) Then
If Not ValidaCveEmpresaUsaurio(UsuarioActual.CveUsuario, Request("CveEmpresa").ToEntero) Then
'Response.Redirect("../Inicio.aspx")
Alert("No tiene acceso a esta empresa.", TipoMensaje.MsgAdvertencia, "document.location.href = ""../Inicio.aspx""")
Exit Sub
End If
End If
CargaDdlPac()
CargaRegimenFiscal()
CargaGridIndicadores()
@@ -159,6 +172,7 @@ Partial Class Sistemas_Empresa
DtFuncionalidades = Nothing
DtCuentas = Nothing
CveClasificacionPorcentaje = 0
If (Request("CveEmpresa") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresa")) AndAlso Request("CveEmpresa").ToEntero > 0 AndAlso UsuarioActual.CveRol = 1) OrElse UsuarioActual.CveRol <> 1 Then
ViewState("CveEmpresa") = If(UsuarioActual.CveRol <> 1, UsuarioActual.Empresa.CveEmpresa.ToString, Request("CveEmpresa")) ' Request("CveEmpresa")
' Session("FileUpload") = CveEmpresa
@@ -207,6 +221,22 @@ Partial Class Sistemas_Empresa
End If
End Sub
Private Function ValidaCveEmpresaUsaurio(CveUsuario As Integer, CveEmpresaValidar As Integer) As Boolean
Dim Respuesta As Boolean = False
Using ObjEmpresas As New ClsSisEmpresas()
If ObjEmpresas.GetEmpresas(-1, "-1", "-1", "-1", "-1", UsuarioActual.CveUsuario) Then
If ObjEmpresas.DtResultados.FiltraParametros($"CveEmpresa = {CveEmpresaValidar}").Rows.Count = 1 Then
Respuesta = True
End If
End If
End Using
Return Respuesta
End Function
Private Sub CargaDatos()
Dim ObjEmpresas As New ClsSisEmpresas()