Bloquear acceso a empersa por url cuando no se es administrador
This commit is contained in:
@@ -6,6 +6,7 @@ Imports Extensiones
|
|||||||
Imports System.Runtime.InteropServices
|
Imports System.Runtime.InteropServices
|
||||||
Imports System.IO
|
Imports System.IO
|
||||||
Imports Microsoft.Reporting.WebForms
|
Imports Microsoft.Reporting.WebForms
|
||||||
|
Imports Microsoft.Owin.Security.Provider
|
||||||
|
|
||||||
Partial Class Sistemas_Empresa
|
Partial Class Sistemas_Empresa
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
@@ -152,6 +153,18 @@ Partial Class Sistemas_Empresa
|
|||||||
|
|
||||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||||
If Not IsPostBack Then
|
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()
|
CargaDdlPac()
|
||||||
CargaRegimenFiscal()
|
CargaRegimenFiscal()
|
||||||
CargaGridIndicadores()
|
CargaGridIndicadores()
|
||||||
@@ -159,6 +172,7 @@ Partial Class Sistemas_Empresa
|
|||||||
DtFuncionalidades = Nothing
|
DtFuncionalidades = Nothing
|
||||||
DtCuentas = Nothing
|
DtCuentas = Nothing
|
||||||
CveClasificacionPorcentaje = 0
|
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
|
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")
|
ViewState("CveEmpresa") = If(UsuarioActual.CveRol <> 1, UsuarioActual.Empresa.CveEmpresa.ToString, Request("CveEmpresa")) ' Request("CveEmpresa")
|
||||||
' Session("FileUpload") = CveEmpresa
|
' Session("FileUpload") = CveEmpresa
|
||||||
@@ -207,6 +221,22 @@ Partial Class Sistemas_Empresa
|
|||||||
End If
|
End If
|
||||||
End Sub
|
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()
|
Private Sub CargaDatos()
|
||||||
|
|
||||||
Dim ObjEmpresas As New ClsSisEmpresas()
|
Dim ObjEmpresas As New ClsSisEmpresas()
|
||||||
|
|||||||
Reference in New Issue
Block a user