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
|
||||
[OperationContract]
|
||||
string VerificarUsuario(CatalogosPostJSON model);
|
||||
CatalogosPostJSON VerificarUsuario(CatalogosPostJSON model);
|
||||
|
||||
[OperationContract]
|
||||
UsuarioExterno BuscarEmail(CatalogosPostJSON model);
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ namespace AYA.SlnSinort.WCF
|
|||
PlantillaEmailDAL PlantillalDAL = new PlantillaEmailDAL();
|
||||
PlantillaEmail plantilla = new PlantillaEmail();
|
||||
List<PlantillaEmail> Listaplantillas = new List<PlantillaEmail>();
|
||||
|
||||
Encriptar encriptar = new Encriptar();
|
||||
int respuesta = 0;
|
||||
|
||||
string email;
|
||||
|
|
@ -980,7 +980,7 @@ namespace AYA.SlnSinort.WCF
|
|||
|
||||
|
||||
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;
|
||||
email = model.UsuarioExterno.Email;
|
||||
correo.DESTINATARIOS = email;
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ namespace AYA.SlnSinort.WCF
|
|||
#endregion
|
||||
|
||||
#region UsuarioExterno
|
||||
public string VerificarUsuario(CatalogosPostJSON model)
|
||||
public CatalogosPostJSON VerificarUsuario(CatalogosPostJSON model)
|
||||
{
|
||||
UsuarioDAL usuarioDal = null;
|
||||
Usuario respuesta = null;
|
||||
|
|
@ -328,18 +328,31 @@ namespace AYA.SlnSinort.WCF
|
|||
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)
|
||||
{
|
||||
log.Error(ex);
|
||||
}
|
||||
return model.codigo;
|
||||
return model;
|
||||
}
|
||||
public UsuarioExterno BuscarEmail(CatalogosPostJSON model) {
|
||||
UsuarioExterno respuesta = null;
|
||||
try
|
||||
{
|
||||
respuesta = new UsuarioExternoDAL().BuscarEmail(model);
|
||||
//respuesta = new UsuarioExternoDAL().BuscarEmail(model);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -353,7 +366,7 @@ namespace AYA.SlnSinort.WCF
|
|||
BaseJson respuesta = new BaseJson();
|
||||
try
|
||||
{
|
||||
respuesta = new UsuarioExternoDAL().InsertarUsuarioExterno(model);
|
||||
//respuesta = new UsuarioExternoDAL().InsertarUsuarioExterno(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ function validarFormulario() {
|
|||
var patron = /^[a-zñA-ZÑ\u00E0-\u00FC]+$/;
|
||||
var nombre;
|
||||
var apellido1;
|
||||
var validacion = 'Los campos son obligatorios';
|
||||
|
||||
if ($('#txtNombre').val().length > 0) {
|
||||
nombre = document.getElementById("txtNombre").value;
|
||||
|
|
@ -55,7 +56,8 @@ function validarFormulario() {
|
|||
Contador++;
|
||||
}
|
||||
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) {
|
||||
|
|
@ -88,7 +90,7 @@ function validarFormulario() {
|
|||
BuscarUsuario(model);
|
||||
|
||||
} 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) {
|
||||
|
||||
var uri = SinorSignupWCF + '/api/VerificarUsuario';
|
||||
AjaxPostData(uri, model, false, true, NombreUsuario, null, null);
|
||||
}
|
||||
this.NombreUsuario = function (data) {
|
||||
usuario = data;
|
||||
LeerFormulario();
|
||||
}
|
||||
this.LeerFormulario = function () {
|
||||
|
||||
UsuarioExterno = {
|
||||
model.UsuarioExterno = {
|
||||
|
||||
Usuario: usuario,
|
||||
Password: $('#txtContrasena').val(),
|
||||
|
|
@ -135,46 +128,32 @@ this.LeerFormulario = function () {
|
|||
Apellido2: $('#txtApellido2').val(),
|
||||
Email: $('#txtEmail').val()
|
||||
}
|
||||
model = {
|
||||
codigo: UsuarioExterno.Email
|
||||
}
|
||||
|
||||
var uri = SinorSignupWCF + '/api/BuscarEmail';
|
||||
AjaxPostData(uri, model, false, false, RegistrarUsuario, null, null);
|
||||
|
||||
var uri = SinorSignupWCF + '/api/VerificarUsuario';
|
||||
AjaxPostData(uri, model, false, true, EnviarCorreo, null, null);
|
||||
|
||||
|
||||
url = $("#hiddenHref").val();
|
||||
url = url.replace("View", "LoginExterno");
|
||||
url = url.replace("Controller", "Login");
|
||||
|
||||
document.location.href = url;
|
||||
|
||||
}
|
||||
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 = url.replace("View", "LoginExterno");
|
||||
url = url.replace("Controller", "Login");
|
||||
|
||||
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
|
||||
= {
|
||||
NombrePlatilla: 'Correo Registro Externo',
|
||||
}
|
||||
|
||||
correo = { }
|
||||
correo = {}
|
||||
correo.PlantillaEmail = Plantilla;
|
||||
correo.UsuarioExterno = UsuarioExterno;
|
||||
correo.UsuarioExterno = data.UsuarioExterno;
|
||||
var uri = SinorLoginWCF + '/api/EnviarCorreoAExterno';
|
||||
AjaxPostData(uri, correo, false, false, null, null, null);
|
||||
AjaxPostData(uri, correo, false, true, null, null, null);
|
||||
|
||||
ENDREQUEST();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
}
|
||||
|
||||
#endregion
|
||||
public UsuarioExterno BuscarEmail(CatalogosPostJSON model)
|
||||
public UsuarioExterno BuscarEmail(string email)
|
||||
{
|
||||
UsuarioExterno usuario = new UsuarioExterno();
|
||||
string filtro = model != null ? model.filtro : null;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
public BaseJson InsertarUsuarioExterno(UsuarioExterno model)
|
||||
public CatalogosPostJSON InsertarUsuarioExterno(CatalogosPostJSON model)
|
||||
{
|
||||
BaseJson Respuesta = new BaseJson();
|
||||
Encriptar encriptar = new Encriptar();
|
||||
try
|
||||
{
|
||||
using (SinortContex Conn = new SinortContex())
|
||||
{
|
||||
model.Password = encriptarContrasena(model.Password);
|
||||
model.Estado = true;
|
||||
model.FechaCreacion = DateTime.Now;
|
||||
Conn.UsuarioExterno.Add(model);
|
||||
model.UsuarioExterno.Password = encriptar.encriptarContrasena(model.UsuarioExterno.Password);
|
||||
model.UsuarioExterno.Estado = true;
|
||||
model.UsuarioExterno.FechaCreacion = DateTime.Now;
|
||||
model.UsuarioExterno.Usuario = model.codigo;
|
||||
Conn.UsuarioExterno.Add(model.UsuarioExterno);
|
||||
Conn.SaveChanges();
|
||||
Conn.Commit();
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||
}
|
||||
}
|
||||
catch (DbEntityValidationException ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
return Respuesta;
|
||||
}
|
||||
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;
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace AYA.SlnSinortModel.Entidades
|
|||
public int? IdTipo { get; set; }
|
||||
public int? IdPantalla { get; set; }
|
||||
public List<Pantallas> pantallas { get; set; }
|
||||
public UsuarioExterno UsuarioExterno { get; set; }
|
||||
}
|
||||
|
||||
public class RolesPantallasJSON : BaseJson
|
||||
|
|
|
|||
|
|
@ -1,15 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
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