Ejemplo n.º 1
0
        public bool CheckPass(Partner partner, string pwd)
        {
            //var pass = Utility.GenerateNewCode(4);
            byte[] salt = Convert.FromBase64String(partner.Extra);
            string hash = Pbkdf2Hasher.ComputeHash(pwd, salt);

            if (hash == partner.Pwd)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool ResetPassword(Partner partner)
        {
            var pass = Utility.GenerateNewCode(4);

            byte[] salt = Pbkdf2Hasher.GenerateRandomSalt();
            string hash = Pbkdf2Hasher.ComputeHash(pass, salt);

            try
            {
                #region Parameters
                var parameters = new List <OracleParameter> {
                    new OracleParameter {
                        ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue
                    },
                    new OracleParameter {
                        ParameterName = "v_partner_acc", OracleDbType = OracleDbType.Varchar2, Value = partner.Account
                    },
                    new OracleParameter {
                        ParameterName = "v_pwd", OracleDbType = OracleDbType.Varchar2, Value = hash
                    },
                    new OracleParameter {
                        ParameterName = "v_extra", OracleDbType = OracleDbType.Varchar2, Value = Convert.ToBase64String(salt)
                    },
                    new OracleParameter {
                        ParameterName = "v_createdby", OracleDbType = OracleDbType.Varchar2, Value = partner.CreatedBy.Id
                    }
                };

                #endregion
                db.ExecuteStoredProc("pk_infra.fn_resetpassword", parameters);
                var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString());

                if (result > 0)
                {
                    var msg = "تم اعادة تعيين الرقم السري الخاص بك الى " + pass;
                    new OutSMSRepo(db).Create(new SMSOut
                    {
                        Receiver = partner.Id,
                        Message  = msg
                    });
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool ChangePwd(int PartnerAcc, string PartnerId, string newPwd, bool notify = true)
        {
            //var pass = Utility.GenerateNewCode(4);
            byte[] salt = Pbkdf2Hasher.GenerateRandomSalt();
            string hash = Pbkdf2Hasher.ComputeHash(newPwd, salt);

            try
            {
                #region Parameters
                var parameters = new List <OracleParameter> {
                    new OracleParameter {
                        ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue
                    },
                    new OracleParameter {
                        ParameterName = "v_partner_acc", OracleDbType = OracleDbType.Int32, Value = PartnerAcc
                    },
                    new OracleParameter {
                        ParameterName = "v_pwd", OracleDbType = OracleDbType.Varchar2, Value = hash
                    },
                    new OracleParameter {
                        ParameterName = "v_extra", OracleDbType = OracleDbType.Varchar2, Value = Convert.ToBase64String(salt)
                    }
                };

                #endregion
                db.ExecuteStoredProc("pk_infra.fn_ChangePassword", parameters);
                var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString());

                if (result > 0)
                {
                    if (notify)
                    {
                        var msg = "تم تغيير الرقم السري الخاصب بك الى " + newPwd;
                        new OutSMSRepo(db).Create(new SMSOut
                        {
                            Receiver = PartnerId,
                            Message  = msg
                        });
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public async Task <OpertionResult> CreateAsync(Partner partner)
        {
            byte[] salt = Pbkdf2Hasher.GenerateRandomSalt();
            string hash = Pbkdf2Hasher.ComputeHash(partner.Pwd, salt);

            try
            {
                #region Parameters
                var parameters = new List <OracleParameter> {
                    new OracleParameter {
                        ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue
                    },
                    new OracleParameter {
                        ParameterName = "v_partner_id", OracleDbType = OracleDbType.Varchar2, Value = partner.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_partner_name", OracleDbType = OracleDbType.NVarchar2, Value = partner.Name
                    },
                    new OracleParameter {
                        ParameterName = "v_brandname", OracleDbType = OracleDbType.NVarchar2, Value = partner.BrandName
                    },
                    new OracleParameter {
                        ParameterName = "v_roleid", OracleDbType = OracleDbType.Int32, Value = partner.Role.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_id_no", OracleDbType = OracleDbType.Int32, Value = partner.PersonalId.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_id_type", OracleDbType = OracleDbType.Int32, Value = partner.PersonalId.IdType.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_id_place", OracleDbType = OracleDbType.NVarchar2, Value = partner.PersonalId.Place
                    },
                    new OracleParameter {
                        ParameterName = "v_id_issued", OracleDbType = OracleDbType.Date, Value = partner.PersonalId.Issued
                    },
                    new OracleParameter {
                        ParameterName = "v_createdby", OracleDbType = OracleDbType.Varchar2, Value = partner.CreatedBy.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_cityid", OracleDbType = OracleDbType.Int32, Value = partner.Address.City.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_districtid", OracleDbType = OracleDbType.Int32, Value = partner.Address.District.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_street", OracleDbType = OracleDbType.NVarchar2, Value = partner.Address.Street
                    },
                    new OracleParameter {
                        ParameterName = "v_zone", OracleDbType = OracleDbType.NVarchar2, Value = partner.Address.Zone
                    },
                    new OracleParameter {
                        ParameterName = "v_extra_address", OracleDbType = OracleDbType.NVarchar2, Value = partner.Address.ExtraInfo
                    },
                    new OracleParameter {
                        ParameterName = "v_pair_mobile", OracleDbType = OracleDbType.Varchar2, Value = partner.PairMobile
                    },
                    new OracleParameter {
                        ParameterName = "v_mobile", OracleDbType = OracleDbType.Varchar2, Value = partner.ContactInfo.Mobile
                    },
                    new OracleParameter {
                        ParameterName = "v_fixed", OracleDbType = OracleDbType.Varchar2, Value = partner.ContactInfo.Fixed
                    },
                    new OracleParameter {
                        ParameterName = "v_fax", OracleDbType = OracleDbType.Varchar2, Value = partner.ContactInfo.Fax
                    },
                    new OracleParameter {
                        ParameterName = "v_email", OracleDbType = OracleDbType.Varchar2, Value = partner.ContactInfo.Email
                    },
                    new OracleParameter {
                        ParameterName = "v_pwd", OracleDbType = OracleDbType.Varchar2, Value = hash
                    },
                    new OracleParameter {
                        ParameterName = "v_extra", OracleDbType = OracleDbType.Varchar2, Value = Convert.ToBase64String(salt)
                    },
                    new OracleParameter {
                        ParameterName = "v_ip_address", OracleDbType = OracleDbType.Varchar2, Value = partner.IPAddress
                    },
                    new OracleParameter {
                        ParameterName = "v_ref_partner", OracleDbType = OracleDbType.Varchar2, Value = partner.RefPartner.Id
                    }
                };

                #endregion
                await db.ExecuteStoredProcAsync("pk_infra.fn_createpartner", parameters);

                var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString());

                if (result > 0)
                {
                    var msg = "تم انشاء حساب لك بخدمة الشاحن الفوري و الرقم السري الخاصب بك هو  " + partner.Pwd;
                    new OutSMSRepo(db).Create(new SMSOut
                    {
                        Receiver = partner.Id,
                        Message  = msg
                    });
                    return(new OpertionResult {
                        AffectedCount = result, Success = true, Error = string.Empty
                    });
                }
                else
                {
                    return(new OpertionResult {
                        AffectedCount = result, Success = false, Error = string.Empty
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OpertionResult {
                    AffectedCount = -1, Success = false, Error = ex.Message
                });
            }
        }