protected void btnLogin_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            Encrypting ObjEncrypting = new Encrypting();

            tbl_UserMasterProp Objtbl_UserMasterProp = new tbl_UserMasterProp();
            Objtbl_UserMasterProp.UserName = ObjEncrypting.Encrypt(txtUserName.Text);
            Objtbl_UserMasterProp.Password = ObjEncrypting.Encrypt(txtPassword.Text);

            tbl_UserMasterBAL Objtbl_UserMasterBAL = new tbl_UserMasterBAL();
            DataSet           dsData = Objtbl_UserMasterBAL.Select_Data(Objtbl_UserMasterProp);
            if (dsData.Tables[0].Rows.Count > 0)
            {
                Session["UserName"] = txtUserName.Text;
                Response.Redirect("HomePage.aspx");
            }
            else
            {
                tdError.Visible   = true;
                tdError.InnerText = "Invalid Username/Password";
            }
        }
        catch (Exception ex)
        {
            tdError.Visible   = true;
            tdError.InnerText = ex.Message;
        }
    }
Beispiel #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        tbl_MatrimonialMemberProp Objtbl_MatrimonialMemberProp = new tbl_MatrimonialMemberProp();

        Objtbl_MatrimonialMemberProp.EmailID = txtEmailID.Text;

        tbl_MatrimonialMemberBAL Objtbl_MatrimonialMemberBAL = new tbl_MatrimonialMemberBAL();
        DataSet dsData = Objtbl_MatrimonialMemberBAL.CheckLogin(Objtbl_MatrimonialMemberProp);

        if (dsData.Tables[0].Rows.Count > 0)
        {
            Encrypting ObjEncrypting = new Encrypting();
            string     DataPassword  = ObjEncrypting.Encrypt(Convert.ToString(dsData.Tables[0].Rows[0]["Password"]));
            if (txtPassword.Text == DataPassword)
            {
                Session["LoginName"] = Convert.ToString(dsData.Tables[0].Rows[0]["MemberName"]);
                Session["LoginID"]   = Convert.ToString(dsData.Tables[0].Rows[0]["MemberCode"]);

                //memberlist.Visible = true;
                matrimonialmemberlist.Visible = true;

                Welcome.Visible   = true;
                LoginForm.Visible = false;
                lblUserName.Text  = Convert.ToString(dsData.Tables[0].Rows[0]["MemberName"]);
            }
            else
            {
                Response.Redirect("MatrimonialSignUp.aspx?msg=invalidpwd");
            }
        }
        else
        {
            Response.Redirect("MatrimonialSignUp.aspx?msg=invalidid");
        }
    }
Beispiel #3
0
        /// <summary>
        /// Método que nos permite registrar un nuevo usuario en el sistema.
        /// </summary>
        /// <param name="usuarioNew">Objeto tipo usuario a registrar</param>
        /// <returns>Id del usuario registrado</returns>
        public static async Task <int> RegistrarUsuario(UsuariosDTO usuarioNew)
        {
            Usuarios user   = null;
            int      result = 0;

            try
            {
                using (OneCoreAdminRepository _repo = new OneCoreAdminRepository())
                {
                    user = new Usuarios()
                    {
                        usuario       = usuarioNew.usuario,
                        contrasena    = Encrypting.Encrypt(usuarioNew.contrasena),
                        estatus       = usuarioNew.estatus,
                        sexo          = usuarioNew.sexo,
                        correo        = usuarioNew.correo,
                        fechaCreacion = DateTime.Now
                    };

                    result = await _repo.AddUserAsync(user);

                    Loggers.WriteInfo(string.Format("SeguridadBL.RegistrarUsuario: Se registro el usuario {0} de forma exitosa", usuarioNew.usuario));

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Método que nos permite autenticar al usuario en el sistema.
        /// </summary>
        /// <param name="usuario">Usuario proporcionado</param>
        /// <param name="contrasena">Contraseña proporcionada</param>
        /// <returns>True en el caso de credenciales sean correctas</returns>
        public static async Task <bool> AutenticarUsuario(string usuario, string contrasena)
        {
            Usuarios user = null;

            try
            {
                using (OneCoreAdminRepository _repo = new OneCoreAdminRepository())
                {
                    user = await _repo.LoginUsuarioAsync(usuario, Encrypting.Encrypt(contrasena));

                    if (user == null)
                    {
                        return(false);
                    }

                    Loggers.WriteInfo(string.Format("SeguridadBL.AutenticarUsuario: Se autentico el usuario {0} de forma exitosa", usuario));

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Método que nos permite actualizar la información de un usuario en particular.
        /// </summary>
        /// <param name="usuarioUpdate">Objeto tipo usuario por actualizar</param>
        /// <returns>Número de registros actualizados</returns>
        public static async Task <int> ActualizarUsuario(UsuariosDTO usuarioUpdate)
        {
            Usuarios user   = null;
            int      result = 0;

            try
            {
                using (OneCoreAdminRepository _repo = new OneCoreAdminRepository())
                {
                    user = new Usuarios()
                    {
                        idUsuario  = usuarioUpdate.idUsuario,
                        usuario    = usuarioUpdate.usuario,
                        contrasena = Encrypting.Encrypt(usuarioUpdate.contrasena),
                        estatus    = usuarioUpdate.estatus,
                        sexo       = usuarioUpdate.sexo,
                        correo     = usuarioUpdate.correo
                    };

                    result = await _repo.UpdateUserAsync(user);

                    Loggers.WriteInfo(string.Format("SeguridadBL.RegistrarUsuario: Se actualizo el usuario {0} de forma exitosa", usuarioUpdate.usuario));

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    protected void imgbtnSave_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            Encrypting ObjEncrypting = new Encrypting();


            tbl_UserMasterProp Objtbl_UserMasterProp = new tbl_UserMasterProp();
            Objtbl_UserMasterProp.UserName = ObjEncrypting.Encrypt(txtUserName.Text);
            Objtbl_UserMasterProp.Password = ObjEncrypting.Encrypt(txtPassword.Text);

            tbl_UserMasterBAL Objtbl_UserMasterBAL = new tbl_UserMasterBAL();
            Objtbl_UserMasterBAL.InsertUpdate_Data(Objtbl_UserMasterProp);
            ShowGuidMessage(1, null);
        }
        catch (Exception ex)
        {
            ShowGuidMessage(0, ex); //MessageBox.Show(ex.Message);
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        tbl_MatrimonialMemberProp Objtbl_MatrimonialMemberProp = new tbl_MatrimonialMemberProp();

        Objtbl_MatrimonialMemberProp.EmailID = txtLoginEmailID.Text;

        tbl_MatrimonialMemberBAL Objtbl_MatrimonialMemberBAL = new tbl_MatrimonialMemberBAL();
        DataSet dsData = Objtbl_MatrimonialMemberBAL.CheckLogin(Objtbl_MatrimonialMemberProp);

        if (dsData.Tables[0].Rows.Count > 0)
        {
            Encrypting ObjEncrypting = new Encrypting();
            string     DataPassword  = ObjEncrypting.Encrypt(Convert.ToString(dsData.Tables[0].Rows[0]["Password"]));
            if (txtLoginPassword.Text == DataPassword)
            {
                Session["LoginName"] = Convert.ToString(dsData.Tables[0].Rows[0]["MemberName"]);
                Session["LoginID"]   = Convert.ToString(dsData.Tables[0].Rows[0]["MemberCode"]);

                Master.FindControl("memberlist").Visible            = true;
                Master.FindControl("matrimonialmemberlist").Visible = true;

                Master.FindControl("Welcome").Visible   = true;
                Master.FindControl("LoginForm").Visible = false;

                if (Convert.ToString(Request.QueryString["msg"]) == "MatrimonialList")
                {
                    Response.Redirect("MatrimonialMembersList.aspx");
                }
                else if (Convert.ToString(Request.QueryString["msg"]) == "MemberList")
                {
                    Response.Redirect("MembersList.aspx");
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
                //memberlist.Visible = true;
                //matrimonialmemberlist.Visible = true;

                //Welcome.Visible = true;
                //LoginForm.Visible = false;
            }
            else
            {
                Response.Redirect("MatrimonialSignUp.aspx?msg=invalidpwd");
            }
        }
        else
        {
            Response.Redirect("MatrimonialSignUp.aspx?msg=invalidid");
        }
    }
Beispiel #8
0
 private User InfoEncryptor(User user)
 {
     user.Firstname = Crypto.Encrypt(user.Firstname);
     user.Lastname  = Crypto.Encrypt(user.Lastname);
     user.Address   = Crypto.Encrypt(user.Address);
     user.Zipcode   = Crypto.Encrypt(user.Zipcode);
     user.Place     = Crypto.Encrypt(user.Place);
     user.Phone     = Crypto.Encrypt(user.Phone);
     user.Email     = Crypto.Encrypt(user.Email);
     return(user);
 }
Beispiel #9
0
 public bool CheckPassword(string password)
 {
     try
     {
         Console.WriteLine(_password);
         string res = Encrypting.Encrypt(password);
         return(_password.CompareTo(res) == 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public async Task SendMessageResetPasswordAsync(string email)
        {
            var isExsist =
                await(await _userRepository.GetAllAsync()).AnyAsync(user =>
                                                                    user.Email.ToUpper().Equals(email.ToUpper()));

            if (!isExsist)
            {
                throw new EntityNotExistException("This email is not exist");
            }
            var tokenToEncrypt = email + "|" +
                                 DateTime.UtcNow.AddMinutes(Convert.ToDouble(_configuration["TimeToResetPassword"]));
            var encryptedText = Encrypting.Encrypt(tokenToEncrypt, _configuration["EncryptionKey"], true);

            encryptedText = HttpUtility.UrlEncode(encryptedText);
            /*var resetPasswordView = File.ReadAllText(@"..\Service\Templates\View\ResetPassword.html");*/
            await _emailService.SendEmailAsync(email, "Password reset",
                                               $"<a href={_configuration["AuthOption:Issuer"]}/change/password/{encryptedText}>Reset password</a>");
        }
    protected void btnSignup_Click(object sender, EventArgs e)
    {
        string sSavePath = "";
        string sFilename = "";

        try
        {
            //if (chkDeleteFilePath.Checked == false)
            //{
            // Set constant values
            sSavePath = "MembersPhotos/";

            // If file field isn’t empty
            if (flFilePath.PostedFile != null && flFilePath.PostedFile.ContentLength > 0)
            {
                // Check file size (mustn’t be 0)
                HttpPostedFile myFile   = flFilePath.PostedFile;
                int            nFileLen = myFile.ContentLength;
                if (nFileLen == 0)
                {
                    ShowGuidMessage(0, new Exception("No file was uploaded."));
                    return;
                }

                // Check file extension (must be JPG or pdf)
                if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
                {
                    ShowGuidMessage(0, new Exception("The file must have an extension of JPG or pdf"));
                    return;
                }

                // Read file into a data stream
                byte[] myData = new Byte[nFileLen];
                myFile.InputStream.Read(myData, 0, nFileLen);

                // Make sure a duplicate file doesn’t exist.  If it does, keep on appending an
                // incremental numeric until it is unique
                sFilename = System.IO.Path.GetFileName(myFile.FileName);
                int file_append = 0;
                while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename)))
                {
                    file_append++;
                    sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
                                + file_append.ToString() + System.IO.Path.GetExtension(myFile.FileName).ToLower();
                }

                // Save the stream to disk
                System.IO.FileStream newFile = new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),
                                                                        System.IO.FileMode.Create);
                newFile.Write(myData, 0, myData.Length);
                newFile.Close();

                // Check whether the file is really a JPEG by opening it
                //System.Drawing.Image.GetThumbnailImageAbort myCallBack =
                //               new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                //Bitmap myBitmap;
                //try
                //{
                //    myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename));

                //    tdUploadedFile.Visible = true;
                //    tdUploadedFile.InnerHtml = "<a href=\"" + sSavePath + sFilename + "\">Download Attachment</a>";

                //    // Displaying success information
                //    //tdError.InnerText = "File uploaded successfully!";

                //    // Destroy objects
                //    myBitmap.Dispose();
                //}
                //catch
                //{
                //    // The file wasn't a valid jpg file
                //    System.IO.File.Delete(Server.MapPath(sSavePath + sFilename));
                //    ShowGuidMessage(0, new Exception("The file wasn't a valid jpg file"));
                //    return;
                //}
            }
            //}
            if (sFilename == "" && Convert.ToInt32(ViewState["EditCode"]) > 0)
            {
                sFilename = Convert.ToString(ViewState["PhotoPath"]);
            }
            else if (sFilename == "" && Convert.ToInt32(ViewState["EditCode"]) <= 0)
            {
                sFilename = "noimage.jpg";
            }
            //else if (chkDeleteFilePath.Checked == true)
            //{
            //    if (Convert.ToInt32(ViewState["EditCode"]) > 0)
            //    {
            //        System.IO.File.Delete(Server.MapPath(sSavePath + Convert.ToString(ViewState["PhotoPath"])));
            //    }
            //    sFilename = "noimage.jpg";
            //}

            tbl_MatrimonialMemberProp Objtbl_MatrimonialMemberProp = new tbl_MatrimonialMemberProp();
            Objtbl_MatrimonialMemberProp.MemberName = Convert.ToString(txtMemberName.Text);
            Objtbl_MatrimonialMemberProp.DOB        = new DateTime(Convert.ToInt32(txtDOB.Text.Split('/')[2]), Convert.ToInt32(txtDOB.Text.Split('/')[1]), Convert.ToInt32(txtDOB.Text.Split('/')[0]));
            Objtbl_MatrimonialMemberProp.Gender     = Convert.ToInt32(rdbtnGender.SelectedValue);
            Objtbl_MatrimonialMemberProp.Gotra      = Convert.ToString(ddlGotra.SelectedItem.Text);
            Objtbl_MatrimonialMemberProp.LivingIn   = Convert.ToInt32(ddlLivingIn.SelectedValue);
            Objtbl_MatrimonialMemberProp.EmailID    = txtEmailID.Text;
            Objtbl_MatrimonialMemberProp.ContactNo  = txtContactNo.Text;

            Encrypting ObjEncrypting = new Encrypting();
            string     DataPassword  = ObjEncrypting.Encrypt(Convert.ToString(txtPassword.Text));

            Objtbl_MatrimonialMemberProp.Password    = DataPassword;
            Objtbl_MatrimonialMemberProp.MemberPhoto = sFilename;

            tbl_MatrimonialMemberBAL Objtbl_MatrimonialMemberBAL = new tbl_MatrimonialMemberBAL();
            Objtbl_MatrimonialMemberBAL.InsertUpdate_Data(Objtbl_MatrimonialMemberProp);

            CommonClass ObjCommonClass = new CommonClass();
            ObjCommonClass.SendMail(txtEmailID.Text, txtPassword.Text, MailMessage());

            ClearPageData();
        }
        catch (Exception ex)
        {
            ShowGuidMessage(0, ex);
        }
    }
Beispiel #12
0
 private void SetPassword(string password)
 {
     _password = Encrypting.Encrypt(password);
 }
Beispiel #13
0
 private void SetPassword(string password)
 {
     Password = Encrypting.Encrypt(password, PrivateKey).Result;
 }