git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C455
This commit is contained in:
parent
677f7f21bc
commit
558b38e51e
7 changed files with 104 additions and 108 deletions
|
|
@ -83,7 +83,7 @@ namespace AYA.SlnSinort.WCF
|
||||||
|
|
||||||
#region UsuarioExterno
|
#region UsuarioExterno
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
string VerificarUsuario(CatalogosPostJSON model);
|
CatalogosPostJSON VerificarUsuario(CatalogosPostJSON model);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
UsuarioExterno BuscarEmail(CatalogosPostJSON model);
|
UsuarioExterno BuscarEmail(CatalogosPostJSON model);
|
||||||
|
|
|
||||||
|
|
@ -955,7 +955,7 @@ namespace AYA.SlnSinort.WCF
|
||||||
PlantillaEmailDAL PlantillalDAL = new PlantillaEmailDAL();
|
PlantillaEmailDAL PlantillalDAL = new PlantillaEmailDAL();
|
||||||
PlantillaEmail plantilla = new PlantillaEmail();
|
PlantillaEmail plantilla = new PlantillaEmail();
|
||||||
List<PlantillaEmail> Listaplantillas = new List<PlantillaEmail>();
|
List<PlantillaEmail> Listaplantillas = new List<PlantillaEmail>();
|
||||||
|
Encriptar encriptar = new Encriptar();
|
||||||
int respuesta = 0;
|
int respuesta = 0;
|
||||||
|
|
||||||
string email;
|
string email;
|
||||||
|
|
@ -980,7 +980,7 @@ namespace AYA.SlnSinort.WCF
|
||||||
|
|
||||||
|
|
||||||
body = plantilla.Body.Replace("$Nombre", model.UsuarioExterno.Nombre).Replace("$Apellido", model.UsuarioExterno.Apellido1)
|
body = plantilla.Body.Replace("$Nombre", model.UsuarioExterno.Nombre).Replace("$Apellido", model.UsuarioExterno.Apellido1)
|
||||||
.Replace("$Usuario", model.UsuarioExterno.Usuario).Replace("$Password", model.UsuarioExterno.Password).Replace("|", "</br>");
|
.Replace("$Usuario", model.UsuarioExterno.Usuario).Replace("$Password",encriptar.desencriptaConstrasena(model.UsuarioExterno.Password)).Replace("|", "</br>");
|
||||||
correo.CUERPO = body;
|
correo.CUERPO = body;
|
||||||
email = model.UsuarioExterno.Email;
|
email = model.UsuarioExterno.Email;
|
||||||
correo.DESTINATARIOS = email;
|
correo.DESTINATARIOS = email;
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ namespace AYA.SlnSinort.WCF
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UsuarioExterno
|
#region UsuarioExterno
|
||||||
public string VerificarUsuario(CatalogosPostJSON model)
|
public CatalogosPostJSON VerificarUsuario(CatalogosPostJSON model)
|
||||||
{
|
{
|
||||||
UsuarioDAL usuarioDal = null;
|
UsuarioDAL usuarioDal = null;
|
||||||
Usuario respuesta = null;
|
Usuario respuesta = null;
|
||||||
|
|
@ -328,18 +328,31 @@ namespace AYA.SlnSinort.WCF
|
||||||
repetido = false;
|
repetido = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.codigo != null)
|
||||||
|
{
|
||||||
|
respuesta2 = new UsuarioExternoDAL().BuscarEmail(model.UsuarioExterno.Email);
|
||||||
|
}
|
||||||
|
if (respuesta2 == null)
|
||||||
|
{
|
||||||
|
model = new UsuarioExternoDAL().InsertarUsuarioExterno(model);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA.ToString();
|
||||||
|
model.DescripcionRespuesta = "El email digitado ya se encuentra registrado";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.Error(ex);
|
log.Error(ex);
|
||||||
}
|
}
|
||||||
return model.codigo;
|
return model;
|
||||||
}
|
}
|
||||||
public UsuarioExterno BuscarEmail(CatalogosPostJSON model) {
|
public UsuarioExterno BuscarEmail(CatalogosPostJSON model) {
|
||||||
UsuarioExterno respuesta = null;
|
UsuarioExterno respuesta = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
respuesta = new UsuarioExternoDAL().BuscarEmail(model);
|
//respuesta = new UsuarioExternoDAL().BuscarEmail(model);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -353,7 +366,7 @@ namespace AYA.SlnSinort.WCF
|
||||||
BaseJson respuesta = new BaseJson();
|
BaseJson respuesta = new BaseJson();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
respuesta = new UsuarioExternoDAL().InsertarUsuarioExterno(model);
|
//respuesta = new UsuarioExternoDAL().InsertarUsuarioExterno(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ function validarFormulario() {
|
||||||
var patron = /^[a-zñA-ZÑ\u00E0-\u00FC]+$/;
|
var patron = /^[a-zñA-ZÑ\u00E0-\u00FC]+$/;
|
||||||
var nombre;
|
var nombre;
|
||||||
var apellido1;
|
var apellido1;
|
||||||
|
var validacion = 'Los campos son obligatorios';
|
||||||
|
|
||||||
if ($('#txtNombre').val().length > 0) {
|
if ($('#txtNombre').val().length > 0) {
|
||||||
nombre = document.getElementById("txtNombre").value;
|
nombre = document.getElementById("txtNombre").value;
|
||||||
|
|
@ -55,7 +56,8 @@ function validarFormulario() {
|
||||||
Contador++;
|
Contador++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastr.warning('El email no es valido', Message_Warning);
|
toastr.warning('El formato de email no es valido', Message_Warning);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($('#txtContrasena').val().length > 0) {
|
if ($('#txtContrasena').val().length > 0) {
|
||||||
|
|
@ -88,7 +90,7 @@ function validarFormulario() {
|
||||||
BuscarUsuario(model);
|
BuscarUsuario(model);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
toastr.warning('Los campos son obligatorios', Message_Warning);
|
toastr.warning(validacion, Message_Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -117,16 +119,7 @@ var normalize = (function () {
|
||||||
})();
|
})();
|
||||||
this.BuscarUsuario = function (model) {
|
this.BuscarUsuario = function (model) {
|
||||||
|
|
||||||
var uri = SinorSignupWCF + '/api/VerificarUsuario';
|
model.UsuarioExterno = {
|
||||||
AjaxPostData(uri, model, false, true, NombreUsuario, null, null);
|
|
||||||
}
|
|
||||||
this.NombreUsuario = function (data) {
|
|
||||||
usuario = data;
|
|
||||||
LeerFormulario();
|
|
||||||
}
|
|
||||||
this.LeerFormulario = function () {
|
|
||||||
|
|
||||||
UsuarioExterno = {
|
|
||||||
|
|
||||||
Usuario: usuario,
|
Usuario: usuario,
|
||||||
Password: $('#txtContrasena').val(),
|
Password: $('#txtContrasena').val(),
|
||||||
|
|
@ -135,36 +128,20 @@ this.LeerFormulario = function () {
|
||||||
Apellido2: $('#txtApellido2').val(),
|
Apellido2: $('#txtApellido2').val(),
|
||||||
Email: $('#txtEmail').val()
|
Email: $('#txtEmail').val()
|
||||||
}
|
}
|
||||||
model = {
|
|
||||||
codigo: UsuarioExterno.Email
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = SinorSignupWCF + '/api/BuscarEmail';
|
var uri = SinorSignupWCF + '/api/VerificarUsuario';
|
||||||
AjaxPostData(uri, model, false, false, RegistrarUsuario, null, null);
|
AjaxPostData(uri, model, false, true, EnviarCorreo, null, null);
|
||||||
}
|
|
||||||
this.RegistrarUsuario = function (data) {
|
|
||||||
|
|
||||||
if (data == null) {
|
|
||||||
var uri = SinorSignupWCF + '/api/InsertarUsuarioExterno';
|
|
||||||
AjaxPostData(uri, UsuarioExterno, false, false, null, null, null);
|
|
||||||
|
|
||||||
|
|
||||||
EnviarCorreo();
|
|
||||||
|
|
||||||
url = $("#hiddenHref").val();
|
url = $("#hiddenHref").val();
|
||||||
url = url.replace("View", "LoginExterno");
|
url = url.replace("View", "LoginExterno");
|
||||||
url = url.replace("Controller", "Login");
|
url = url.replace("Controller", "Login");
|
||||||
|
|
||||||
document.location.href = url;
|
document.location.href = url;
|
||||||
}
|
|
||||||
else {
|
|
||||||
toastr.error('El email digitado ya se encuentra registrado', Message_Warning);
|
|
||||||
ENDREQUEST();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.EnviarCorreo = function()
|
|
||||||
{
|
this.EnviarCorreo = function (data) {
|
||||||
var Plantilla
|
var Plantilla
|
||||||
= {
|
= {
|
||||||
NombrePlatilla: 'Correo Registro Externo',
|
NombrePlatilla: 'Correo Registro Externo',
|
||||||
|
|
@ -172,9 +149,11 @@ this.EnviarCorreo = function()
|
||||||
|
|
||||||
correo = {}
|
correo = {}
|
||||||
correo.PlantillaEmail = Plantilla;
|
correo.PlantillaEmail = Plantilla;
|
||||||
correo.UsuarioExterno = UsuarioExterno;
|
correo.UsuarioExterno = data.UsuarioExterno;
|
||||||
var uri = SinorLoginWCF + '/api/EnviarCorreoAExterno';
|
var uri = SinorLoginWCF + '/api/EnviarCorreoAExterno';
|
||||||
AjaxPostData(uri, correo, false, false, null, null, null);
|
AjaxPostData(uri, correo, false, true, null, null, null);
|
||||||
|
|
||||||
ENDREQUEST();
|
ENDREQUEST();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
public UsuarioExterno BuscarEmail(CatalogosPostJSON model)
|
public UsuarioExterno BuscarEmail(string email)
|
||||||
{
|
{
|
||||||
UsuarioExterno usuario = new UsuarioExterno();
|
UsuarioExterno usuario = new UsuarioExterno();
|
||||||
string filtro = model != null ? model.filtro : null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
usuario = db.UsuarioExterno.Where(r => r.Email.ToString() == model.codigo).FirstOrDefault();
|
usuario = db.UsuarioExterno.Where(r => r.Email.ToString() == email).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -70,74 +70,35 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
||||||
|
|
||||||
return usuario;
|
return usuario;
|
||||||
}
|
}
|
||||||
public BaseJson InsertarUsuarioExterno(UsuarioExterno model)
|
public CatalogosPostJSON InsertarUsuarioExterno(CatalogosPostJSON model)
|
||||||
{
|
{
|
||||||
BaseJson Respuesta = new BaseJson();
|
Encriptar encriptar = new Encriptar();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (SinortContex Conn = new SinortContex())
|
using (SinortContex Conn = new SinortContex())
|
||||||
{
|
{
|
||||||
model.Password = encriptarContrasena(model.Password);
|
model.UsuarioExterno.Password = encriptar.encriptarContrasena(model.UsuarioExterno.Password);
|
||||||
model.Estado = true;
|
model.UsuarioExterno.Estado = true;
|
||||||
model.FechaCreacion = DateTime.Now;
|
model.UsuarioExterno.FechaCreacion = DateTime.Now;
|
||||||
Conn.UsuarioExterno.Add(model);
|
model.UsuarioExterno.Usuario = model.codigo;
|
||||||
|
Conn.UsuarioExterno.Add(model.UsuarioExterno);
|
||||||
Conn.SaveChanges();
|
Conn.SaveChanges();
|
||||||
Conn.Commit();
|
Conn.Commit();
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DbEntityValidationException ex)
|
catch (DbEntityValidationException ex)
|
||||||
{
|
{
|
||||||
log.Error(ex);
|
log.Error(ex);
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.Error(ex);
|
log.Error(ex);
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||||
}
|
}
|
||||||
return Respuesta;
|
return model;
|
||||||
}
|
|
||||||
public static byte[] Clave = Encoding.ASCII.GetBytes("f7QkGjna2q2");
|
|
||||||
public static byte[] IV = Encoding.ASCII.GetBytes("Devjoker7.37hAES");
|
|
||||||
|
|
||||||
public static String encriptarContrasena(String Cadena)
|
|
||||||
{
|
|
||||||
byte[] inputBytes = Encoding.ASCII.GetBytes(Cadena);
|
|
||||||
byte[] encripted;
|
|
||||||
RijndaelManaged cripto = new RijndaelManaged();
|
|
||||||
using (MemoryStream ms = new MemoryStream(inputBytes.Length))
|
|
||||||
{
|
|
||||||
using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateEncryptor(Clave, IV), CryptoStreamMode.Write))
|
|
||||||
{
|
|
||||||
objCryptoStream.Write(inputBytes, 0, inputBytes.Length);
|
|
||||||
objCryptoStream.FlushFinalBlock();
|
|
||||||
objCryptoStream.Close();
|
|
||||||
}
|
|
||||||
encripted = ms.ToArray();
|
|
||||||
}
|
|
||||||
return Convert.ToBase64String(encripted);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String desencriptaConstrasena(string Cadena)
|
|
||||||
{
|
|
||||||
|
|
||||||
byte[] inputBytes = Convert.FromBase64String(Cadena);
|
|
||||||
byte[] resultBytes = new byte[inputBytes.Length];
|
|
||||||
string textoLimpio = String.Empty;
|
|
||||||
RijndaelManaged cripto = new RijndaelManaged();
|
|
||||||
using (MemoryStream ms = new MemoryStream(inputBytes))
|
|
||||||
{
|
|
||||||
using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateDecryptor(Clave, IV), CryptoStreamMode.Read))
|
|
||||||
{
|
|
||||||
using (StreamReader sr = new StreamReader(objCryptoStream, true))
|
|
||||||
{
|
|
||||||
textoLimpio = sr.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return textoLimpio;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ namespace AYA.SlnSinortModel.Entidades
|
||||||
public int? IdTipo { get; set; }
|
public int? IdTipo { get; set; }
|
||||||
public int? IdPantalla { get; set; }
|
public int? IdPantalla { get; set; }
|
||||||
public List<Pantallas> pantallas { get; set; }
|
public List<Pantallas> pantallas { get; set; }
|
||||||
|
public UsuarioExterno UsuarioExterno { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RolesPantallasJSON : BaseJson
|
public class RolesPantallasJSON : BaseJson
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,57 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Atesa.Utilitarios
|
namespace Atesa.Utilitarios
|
||||||
{
|
{
|
||||||
class Encriptar
|
public class Encriptar
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static byte[] Clave = Encoding.ASCII.GetBytes("f7QkGjna2q2");
|
||||||
|
public static byte[] IV = Encoding.ASCII.GetBytes("Devjoker7.37hAES");
|
||||||
|
|
||||||
|
public String encriptarContrasena(String Cadena)
|
||||||
|
{
|
||||||
|
byte[] inputBytes = Encoding.ASCII.GetBytes(Cadena);
|
||||||
|
byte[] encripted;
|
||||||
|
RijndaelManaged cripto = new RijndaelManaged();
|
||||||
|
using (MemoryStream ms = new MemoryStream(inputBytes.Length))
|
||||||
|
{
|
||||||
|
using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateEncryptor(Clave, IV), CryptoStreamMode.Write))
|
||||||
|
{
|
||||||
|
objCryptoStream.Write(inputBytes, 0, inputBytes.Length);
|
||||||
|
objCryptoStream.FlushFinalBlock();
|
||||||
|
objCryptoStream.Close();
|
||||||
|
}
|
||||||
|
encripted = ms.ToArray();
|
||||||
|
}
|
||||||
|
return Convert.ToBase64String(encripted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String desencriptaConstrasena(string Cadena)
|
||||||
|
{
|
||||||
|
|
||||||
|
byte[] inputBytes = Convert.FromBase64String(Cadena);
|
||||||
|
byte[] resultBytes = new byte[inputBytes.Length];
|
||||||
|
string textoLimpio = String.Empty;
|
||||||
|
RijndaelManaged cripto = new RijndaelManaged();
|
||||||
|
using (MemoryStream ms = new MemoryStream(inputBytes))
|
||||||
|
{
|
||||||
|
using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateDecryptor(Clave, IV), CryptoStreamMode.Read))
|
||||||
|
{
|
||||||
|
using (StreamReader sr = new StreamReader(objCryptoStream, true))
|
||||||
|
{
|
||||||
|
textoLimpio = sr.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return textoLimpio;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue