-- cambio de función de cambio de contraseña desde login. de clsususario a clsusiariovalidación
This commit is contained in:
@@ -354,6 +354,7 @@ Public Class ClsSisUsuarioAutenticacion
|
||||
Retorno.FechaUltimoAcceso = Data.Rows(0)("FechaUltimoAcceso").ToString().ToDate()
|
||||
Retorno.FechaUltimoCambioContraseña = Data.Rows(0)("FechaUltimoCambioContraseña").ToString().ToDate()
|
||||
Retorno.ActCambiarContraseña = If(Data.Rows(0)("ActCambiarContraseña").ToString() = "SI", True, False)
|
||||
Retorno.PolCambiarContraseña = If(Data.Rows(0)("PolCambiarContraseña").ToString() = "SI", True, False)
|
||||
Retorno.TipoControl = Data.Rows(0)("TipoControl").ToString().ToEntero()
|
||||
'*
|
||||
Retorno.CveProveedor = Data.Rows(0)("CveProveedor").ToString().ToEntero()
|
||||
@@ -400,6 +401,35 @@ Public Class ClsSisUsuarioAutenticacion
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function UpdateUsuarioContrasenia(Contrasenia As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
|
||||
DataAdapter("UPDATE U SET [Contraseña] = @Contrasenia, FechaUltimoCambioContraseña = GETDATE() FROM Usuarios U WHERE U.CveUsuario = @CveUsuario ", CommandType.Text)
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
|
||||
.Add("@Contrasenia", SqlDbType.VarChar).Value = Contrasenia
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Alert("Ya existe un Usuario con el mismo nombre: " & Usuario & ".", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al guardar los cambios en el Usuario", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar los cambios en el Usuario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
'Public Function ValidaUsuarioAsignacion(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
||||
' Dim Retorno As Usuario = Nothing
|
||||
|
||||
|
||||
@@ -723,34 +723,6 @@ Public Class ClsSisUsuarios
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
Public Function UpdateUsuarioContrasenia(Contrasenia As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
|
||||
DataAdapter("UPDATE U SET [Contraseña] = @Contrasenia, FechaUltimoCambioContraseña = GETDATE() FROM Usuarios U WHERE U.CveUsuario = @CveUsuario ", CommandType.Text)
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
|
||||
.Add("@Contrasenia", SqlDbType.VarChar).Value = Contrasenia
|
||||
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch Ex1 As SqlException
|
||||
If Ex1.Message.Contains("Número: 2627;") Then
|
||||
Alert("Ya existe un Usuario con el mismo nombre: " & Usuario & ".", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Me.OnError("Ocurrió un error al guardar los cambios en el Usuario", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al guardar los cambios en el Usuario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
Public Function RemoveUsuario(CveUsuario As Integer) As Boolean
|
||||
Dim Retorno As Boolean = False
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Public Class Usuario
|
||||
Public Property CveSubProyecto As Integer
|
||||
Public Property FechaUltimoAcceso As Date
|
||||
Public Property FechaUltimoCambioContraseña As Date
|
||||
'Public Property PolCambiarContraseña As Boolean
|
||||
Public Property PolCambiarContraseña As Boolean
|
||||
Public Property ActCambiarContraseña As Boolean
|
||||
Public Property CveProveedor As Integer
|
||||
Public Property CveVendedor As Integer
|
||||
|
||||
@@ -116,35 +116,25 @@ Partial Class LogIn
|
||||
PnlLogin.Visible = False
|
||||
|
||||
If elapsedSpan.Days < 3 Then
|
||||
Dim tGrupoEmpresa As String = ClsPaginas.GlobalGrupoEmpresa(Request.Url.Host.ToUpper())
|
||||
Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexionDominio(Request.Url.Host.ToUpper())
|
||||
|
||||
Dim Usr As New ClsSisUsuarios
|
||||
If Usr.GetUsuarios(CveUsuario, -1, -1) Then
|
||||
Dim ObjUsuario As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena)
|
||||
Dim Usuario As Usuario = ObjUsuario.GetUsuarioDetalle(CveUsuario, CveEmpresa:=CveEmpresa)
|
||||
|
||||
Dim dr As DataRow = Usr.DtResultados.FiltroPrimero("")
|
||||
|
||||
If dr IsNot Nothing Then
|
||||
If dr("PolCambiarContraseña").ToString = "SI" Then
|
||||
PnlContra.Visible = True
|
||||
'HCambio.Visible = True
|
||||
'HdnCveUsr.Value = CveUsuario.ToString
|
||||
Me.Form.DefaultButton = BtnGuardar.ClientID
|
||||
'If Usr.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString,
|
||||
' dr("Permiso1").ToString = "True", dr("Permiso2").ToString = "True", dr("Permiso3").ToString = "True", dr("Permiso4").ToString = "True", dr("Permiso5").ToString = "True",
|
||||
' dr("Permiso6").ToString = "True", dr("Permiso7").ToString = "True", dr("Permiso8").ToString = "True", dr("Permiso9").ToString = "True", dr("Permiso10").ToString = "True",
|
||||
' True, TxtContrasenia1.Text, dr("CveCliente").ToString.ToEntero, dr("CveProveedor").ToString.ToEntero, CveUsr) Then
|
||||
|
||||
' Alert("Contraseña Modificada.", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="location.href=""ConsultaCliente.aspx""")
|
||||
|
||||
'End If
|
||||
Else
|
||||
Alert("El usuario ya cambio su contraseña, inicie sesión normalmente.", TipoMensaje.MsgInformacion)
|
||||
PnlLogin.Visible = True
|
||||
End If
|
||||
If Usuario IsNot Nothing Then
|
||||
If Usuario.PolCambiarContraseña Then
|
||||
PnlContra.Visible = True
|
||||
Me.Form.DefaultButton = BtnGuardar.ClientID
|
||||
Else
|
||||
Alert("El Usuario no existe", TipoMensaje.MsgError)
|
||||
Alert("El usuario ya cambio su contraseña, inicie sesión normalmente.", TipoMensaje.MsgInformacion)
|
||||
PnlLogin.Visible = True
|
||||
End If
|
||||
Else
|
||||
Alert("El Usuario no existe", TipoMensaje.MsgError)
|
||||
End If
|
||||
Usr.Dispose()
|
||||
ObjUsuario.Dispose()
|
||||
Usuario = Nothing
|
||||
Else
|
||||
Alert("La Activación expiró", TipoMensaje.MsgError)
|
||||
End If
|
||||
@@ -177,20 +167,6 @@ Partial Class LogIn
|
||||
Return URLParametros
|
||||
End Function
|
||||
|
||||
'Property GlobalDTUsuarios(Optional CveUsuario As Integer = -1, Optional CveEmpresa As Integer = -1) As Data.DataTable
|
||||
' Get
|
||||
' If CveUsuario <> -1 Then
|
||||
' Dim Dv As New Data.DataView(DirectCast(Application("GlobalDTUsuarios"), Data.DataTable), "CveUsuario =" & CveUsuario, "", Data.DataViewRowState.CurrentRows)
|
||||
' GlobalDTUsuarios = Dv.ToTable
|
||||
' Dv.Dispose()
|
||||
' Else
|
||||
' GlobalDTUsuarios = DirectCast(Application("GlobalDTUsuarios"), Data.DataTable)
|
||||
' End If
|
||||
' End Get
|
||||
' Set(value As Data.DataTable)
|
||||
' Application("GlobalDTUsuarios") = value
|
||||
' End Set
|
||||
'End Property
|
||||
Dim BtnLogIn_Clickenter As Integer = 0
|
||||
Protected Sub BtnLogIn_Click(ByVal sender As Object, ByVal e As EventArgs) 'Handles CmdLogIn.Click
|
||||
Dim ReturnUrl As String = "/"
|
||||
@@ -218,7 +194,6 @@ Partial Class LogIn
|
||||
If Usuario IsNot Nothing Then
|
||||
If Not Usuario.AutorizadoxIP OrElse (HddAdsCodex.Text.Length > 0 AndAlso Usuario.CodigoAutorizado = HddAdsCodex.Text) Then
|
||||
|
||||
'CreaObjetoEmpresa(Usuario, NombreCadena)
|
||||
ADSSessionConfig.sessionUser.MultipleEmpresa = True
|
||||
|
||||
Dim x As New ADSSessionObj(Usuario.CveUsuario, Usuario.CveEmpresa)
|
||||
@@ -227,21 +202,14 @@ Partial Class LogIn
|
||||
|
||||
If Usuario.CvePlataforma = 6 And Usuario.CveRol = 10 Then
|
||||
'PLATAFORMA PORTAL CLIENTE
|
||||
'FormsAuthentication.RedirectFromLoginPage(_sessionid, False)
|
||||
'Response.Redirect("/PortalCliente/PortalCliente.aspx", True)
|
||||
|
||||
ReturnUrl = "/PortalCliente/PortalCliente.aspx"
|
||||
If Usuario.CveEmpresa = 194 Then ReturnUrl = "/Ventas/RepPedidosSTF.aspx"
|
||||
ElseIf Usuario.CvePlataforma = 7 And Usuario.CveRol = 11 Then
|
||||
'PLATAFORMA PORTAL PROVEEDOR
|
||||
'FormsAuthentication.RedirectFromLoginPage(Encripta(Usuario.CveUsuario), False)
|
||||
'Response.Redirect("/PortalProveedor/PortalProveedor.aspx", True)
|
||||
|
||||
ReturnUrl = "/PortalProveedor/PortalProveedor.aspx"
|
||||
ElseIf Usuario.CveRol = 1200 And Usuario.Acceso > 0 Then
|
||||
'PLATAFORMA GPS
|
||||
Usuario.CvePlataforma = 3
|
||||
'FormsAuthentication.RedirectFromLoginPage(Encripta(Usuario.CveUsuario), False)
|
||||
'Response.Redirect("/PortalGPS/InicioGPS.aspx", True)
|
||||
ReturnUrl = "/PortalGPS/InicioGPS.aspx"
|
||||
Else
|
||||
'PLATAFORMA SIG
|
||||
@@ -308,51 +276,28 @@ Partial Class LogIn
|
||||
End If
|
||||
|
||||
End Function
|
||||
'Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario, Optional NombreCadena As String = "Conexion")
|
||||
|
||||
' Dim ObjEmpresa As New ClsSisEmpresas(UsuarioActual:=UsuarioActual)
|
||||
' If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
||||
' If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa) Then
|
||||
' Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
||||
|
||||
' Dim EmpresasFuncionalidades As New HybridDictionary
|
||||
' For Each Row As Data.DataRow In dttmp.Rows
|
||||
' EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
||||
' Next
|
||||
' ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
||||
' End If
|
||||
|
||||
' UsuarioActual.Empresa = ObjEmpresa.Empresa
|
||||
' Else
|
||||
' End If
|
||||
' ObjEmpresa.Dispose()
|
||||
'End Sub
|
||||
Dim BtnGuardar_Clickenter As Integer = 0
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
||||
If BtnGuardar_Clickenter = 0 Then 'esta variable se recicla con cada postaback
|
||||
BtnGuardar_Clickenter = 1
|
||||
Dim TieneError As Boolean = False
|
||||
Dim ObjUsuario As New ClsSisUsuarios
|
||||
Dim tGrupoEmpresa As String = ClsPaginas.GlobalGrupoEmpresa(Request.Url.Host.ToUpper())
|
||||
Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexionDominio(Request.Url.Host.ToUpper())
|
||||
|
||||
Dim ObjUsuario As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena)
|
||||
If ObjUsuario.UpdateUsuarioContrasenia(Encripta(TxtContrasenia1.Text), CveUsuario, CveEmpresa) Then
|
||||
If ObjUsuario.GetUsuarios(CveUsuario) Then
|
||||
If ObjUsuario.DtResultados.Rows.Count = 1 Then
|
||||
Dim dr As DataRow = ObjUsuario.DtResultados.Rows(0)
|
||||
Dim Usuario As Usuario = ObjUsuario.GetUsuarioDetalle(CveUsuario, CveEmpresa:=CveEmpresa)
|
||||
|
||||
txtUsuario.Text = dr("Usuario").ToString
|
||||
Dim Contraseña As String = Decripta(dr("Contraseña").ToString)
|
||||
TxtContraseña.Text = Contraseña
|
||||
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
If Usuario IsNot Nothing Then
|
||||
txtUsuario.Text = Usuario.Usuario
|
||||
TxtContraseña.Text = TxtContrasenia1.Text
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
ObjUsuario.Dispose()
|
||||
|
||||
If Not TieneError Then
|
||||
|
||||
Reference in New Issue
Block a user