Exemplo n.º 1
0
        public static string Encrypt(long userId, string controllerName)
        {
            string text = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey;

            if (string.IsNullOrEmpty(text))
            {
                text = SecureHelper.MD5(Guid.NewGuid().ToString());
                Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", text);
            }
            string text2 = string.Empty;
            string result;

            try
            {
                string encryptStr = controllerName + "," + userId.ToString();
                text2  = SecureHelper.AESEncrypt(encryptStr, text);
                text2  = SecureHelper.EncodeBase64(text2);
                result = text2;
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("加密用户标识Cookie出错", text2), exception);
                throw;
            }
            return(result);
        }
Exemplo n.º 2
0
        public bool AddChileRole(ManagerInfo managerInfo, UserMemberInfo userInfo)
        {
            int i = 0;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                managerInfo.PasswordSalt = Guid.NewGuid().ToString();
                managerInfo.CreateDate   = DateTime.Now;
                string str = SecureHelper.MD5(managerInfo.Password);
                managerInfo.Password = SecureHelper.MD5(string.Concat(str, managerInfo.PasswordSalt));
                context.ManagerInfo.Add(managerInfo);
                userInfo.PasswordSalt = managerInfo.PasswordSalt;
                userInfo.CreateDate   = DateTime.Now;
                userInfo.Password     = SecureHelper.MD5(string.Concat(str, userInfo.PasswordSalt));
                context.UserMemberInfo.Add(userInfo);
                i = context.SaveChanges();
                transactionScope.Complete();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public static long Decrypt(string userIdCookie, string controllerName)
        {
            string text = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey;

            if (string.IsNullOrEmpty(text))
            {
                text = SecureHelper.MD5(Guid.NewGuid().ToString());
                Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", text);
            }
            string text2 = string.Empty;

            try
            {
                if (!string.IsNullOrWhiteSpace(userIdCookie))
                {
                    userIdCookie = HttpUtility.UrlDecode(userIdCookie);
                    userIdCookie = SecureHelper.DecodeBase64(userIdCookie);
                    text2        = SecureHelper.AESDecrypt(userIdCookie, text);
                    text2        = text2.Replace(controllerName + ",", "");
                }
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("解密用户标识Cookie出错,Cookie密文:{0}", userIdCookie), exception);
            }
            long result = 0L;

            long.TryParse(text2, out result);
            return(result);
        }
Exemplo n.º 4
0
        private static string GetKey(string host)
        {
            var firstMD5 = SecureHelper.MD5(host);
            var result   = SecureHelper.MD5(firstMD5 + host);

            return(result);
        }
Exemplo n.º 5
0
        public JsonResult ChangePassword(string oldpassword, string password)
        {
            if (string.IsNullOrWhiteSpace(oldpassword) || string.IsNullOrWhiteSpace(password))
            {
                Result result = new Result()
                {
                    success = false,
                    msg     = "密码不能为空!"
                };
                return(Json(result));
            }
            IPaltManager currentManager = base.CurrentManager;

            if (SecureHelper.MD5(string.Concat(SecureHelper.MD5(oldpassword), currentManager.PasswordSalt)) != currentManager.Password)
            {
                Result result1 = new Result()
                {
                    success = false,
                    msg     = "旧密码错误"
                };
                return(Json(result1));
            }
            ServiceHelper.Create <IManagerService>().ChangePlatformManagerPassword(currentManager.Id, password, 0);
            Result result2 = new Result()
            {
                success = true,
                msg     = "修改成功"
            };

            return(Json(result2));
        }
Exemplo n.º 6
0
        protected override object ChangePasswordByOldPassword(string oldPassword, string password)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                return(ErrorResult("密码不能为空"));
            }

            if (string.IsNullOrWhiteSpace(oldPassword))
            {
                return(ErrorResult("旧密码输入错误"));
            }
            CheckUserLogin();

            var user = CurrentUser;

            var pwd = SecureHelper.MD5(SecureHelper.MD5(oldPassword) + user.PasswordSalt);

            if (pwd == user.Password)
            {
                Application.ManagerApplication.ChangeSellerManagerPassword(user.Id, user.ShopId, password, user.RoleId);
                if (CurrentUser.RoleId == 0)
                {
                    Application.MemberApplication.ChangePassword(user.UserName, password);//修改诊所对应的用户密码
                }

                return(SuccessResult("密码修改成功"));
            }

            return(ErrorResult("旧密码输入不正确"));
        }
Exemplo n.º 7
0
        public JsonResult ChangePassword(string oldpassword, string password)
        {
            if (string.IsNullOrWhiteSpace(oldpassword) || string.IsNullOrWhiteSpace(password))
            {
                Result result = new Result()
                {
                    success = false,
                    msg     = "Password is require!"
                };
                return(Json(result));
            }
            UserMemberInfo currentUser = base.CurrentUser;

            if (SecureHelper.MD5(string.Concat(SecureHelper.MD5(oldpassword), currentUser.PasswordSalt)) != currentUser.Password)
            {
                Result result1 = new Result()
                {
                    success = false,
                    msg     = "Old password is error"
                };
                return(Json(result1));
            }
            ServiceHelper.Create <IMemberService>().ChangePassWord(currentUser.Id, password);
            Result result2 = new Result()
            {
                success = true,
                msg     = "Password Has Been Changed"
            };

            return(Json(result2));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 二次加盐后的密码
        /// </summary>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        public static string GetPasswrodEncode(string password, string salt)
        {
            string encryptedPassword         = SecureHelper.MD5(password);                 //一次MD5加密
            string encryptedWithSaltPassword = SecureHelper.MD5(encryptedPassword + salt); //一次结果加盐后二次加密

            return(encryptedWithSaltPassword);
        }
Exemplo n.º 9
0
        public bool AddSellerManager(ManagerInfo model, string currentSellerName)
        {
            if (model.RoleId == 0)
            {
                throw new HimallException("权限组选择不正确!");
            }
            if (CheckUserNameExist(model.UserName, false))
            {
                throw new HimallException("该用户名已存在!");
            }
            if (model.ShopId == 0)
            {
                throw new HimallException("没有权限进行该操作!");
            }
            model.PasswordSalt = Guid.NewGuid().ToString();
            model.CreateDate   = DateTime.Now;
            string str = SecureHelper.MD5(model.Password);

            model.Password = SecureHelper.MD5(string.Concat(str, model.PasswordSalt));
            context.ManagerInfo.Add(model);
            int i = context.SaveChanges();

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        public static string Encrypt(long userId, string controllerName)
        {
            string str;
            string userCookieKey = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey;

            if (string.IsNullOrEmpty(userCookieKey))
            {
                Guid guid = Guid.NewGuid();
                userCookieKey = SecureHelper.MD5(guid.ToString());
                Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", userCookieKey);
            }
            string empty = string.Empty;

            try
            {
                string str1 = string.Concat(controllerName, ",", userId.ToString());
                empty = SecureHelper.AESEncrypt(str1, userCookieKey);
                empty = SecureHelper.EncodeBase64(empty);
                str   = empty;
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("加密用户标识Cookie出错", empty), exception);
                throw;
            }
            return(str);
        }
Exemplo n.º 11
0
        public static long Decrypt(string userIdCookie, string controllerName)
        {
            string userCookieKey = Instance <ISiteSettingService> .Create.GetSiteSettings().UserCookieKey;

            if (string.IsNullOrEmpty(userCookieKey))
            {
                Guid guid = Guid.NewGuid();
                userCookieKey = SecureHelper.MD5(guid.ToString());
                Instance <ISiteSettingService> .Create.SaveSetting("UserCookieKey", userCookieKey);
            }
            string empty = string.Empty;

            try
            {
                if (!string.IsNullOrWhiteSpace(userIdCookie))
                {
                    userIdCookie = HttpUtility.UrlDecode(userIdCookie);
                    userIdCookie = SecureHelper.DecodeBase64(userIdCookie);
                    empty        = SecureHelper.AESDecrypt(userIdCookie, userCookieKey);
                    empty        = empty.Replace(string.Concat(controllerName, ","), "");
                }
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("解密用户标识Cookie出错,Cookie密文:{0}", userIdCookie), exception);
            }
            long num = 0;

            long.TryParse(empty, out num);
            return(num);
        }
Exemplo n.º 12
0
        public ActionResult ModyPwd(UserInfo user)
        {
            OperationResult result = null;
            string          newpwd = this.Request.Form["newpwd"];

            if (string.IsNullOrEmpty(newpwd))
            {
                return(Json(new { r = false, m = "密码不能为空" }, JsonRequestBehavior.AllowGet));
            }

            string oldpwd = this.Request.Form["opwd"];

            var old = unitOfWork.DUserInfo.GetByID(user.ID);

            if (SecureHelper.MD5(oldpwd) != old.Pwd)
            {
                return(Json(new { r = false, m = "密码不正确" }, JsonRequestBehavior.AllowGet));
            }

            old.Pwd = SecureHelper.MD5(newpwd);
            unitOfWork.DUserInfo.Update(old);
            result = unitOfWork.Save();
            new DBLogService().insert(ActionClick.Other, user, "修改密码");
            if (result.ResultType == OperationResultType.Success)
            {
                return(Json(new { r = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { r = false, m = "操作失败\n" + result.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 13
0
        protected override object ChangePasswordByOldPassword(string oldPassword, string password)
        {
            CheckUserLogin();

            var _iMemberService = ServiceProvider.Instance <IMemberService> .Create;

            if (string.IsNullOrWhiteSpace(oldPassword) || string.IsNullOrWhiteSpace(password))
            {
                return(Json(new { success = false, msg = "密码不能为空!" }));
            }
            var  model     = CurrentUser;
            var  pwd       = SecureHelper.MD5(SecureHelper.MD5(oldPassword) + model.PasswordSalt);
            bool CanChange = false;

            if (pwd == model.Password)
            {
                CanChange = true;
            }
            if (model.PasswordSalt.StartsWith("o"))
            {
                CanChange = true;
            }
            if (CanChange)
            {
                Application.MemberApplication.ChangePassword(model.Id, password);
                return(SuccessResult("密码修改成功"));
            }
            else
            {
                return(ErrorResult("旧密码错误"));
            }
        }
Exemplo n.º 14
0
        public JsonResult ChangePassword(string oldpassword, string password)
        {
            if (string.IsNullOrWhiteSpace(oldpassword) || string.IsNullOrWhiteSpace(password))
            {
                return(Json(new Result()
                {
                    success = false, msg = "密码不能为空!"
                }));
            }
            var model = CurrentSellerManager;
            var pwd   = SecureHelper.MD5(SecureHelper.MD5(oldpassword) + model.PasswordSalt);

            if (pwd == model.Password)
            {
                _iManagerService.ChangeSellerManagerPassword(CurrentSellerManager.Id, CurrentSellerManager.ShopId, password, CurrentSellerManager.RoleId);
                return(Json(new Result()
                {
                    success = true, msg = "修改成功"
                }));
            }
            else
            {
                return(Json(new Result()
                {
                    success = false, msg = "旧密码错误"
                }));
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 短信验证成功后创建验证成功凭证
        /// </summary>
        /// <param name="contact"></param>
        /// <returns></returns>
        protected override string CreateCertificate(string contact)
        {
            CheckShopManageLogin();
            var identity = CurrentUser.Id.ToString();

            identity = SecureHelper.MD5(identity + _encryptKey);
            return(identity);
        }
Exemplo n.º 16
0
        public ManagerInfo GetManageInfoByPwd(long manId, string password)
        {
            ManagerInfo userMemberInfo = context.ManagerInfo.FirstOrDefault((ManagerInfo e) => e.Id == manId);

            if (userMemberInfo != null && SecureHelper.MD5(string.Concat(SecureHelper.MD5(password.Trim()), userMemberInfo.PasswordSalt)) == userMemberInfo.Password)
            {
                return(userMemberInfo);
            }
            return(null);
        }
Exemplo n.º 17
0
        public ActionResult Login(Models.ViewModelLogin viewModelLogin)
        {
            //登陆错误次数限制
            if (Session[SessionKey.Login_Fail_Total] != null)
            {
                if (TypeHelper.ObjectToInt(Session[SessionKey.Login_Fail_Total]) > 3)
                {
                    ModelState.AddModelError("user_name", "失败次数过多,重启浏览器后再试");
                    return(View(viewModelLogin));
                }
            }

            if (ModelState.IsValid)
            {
                string passworld = SecureHelper.MD5(viewModelLogin.password);

                BLL.BaseBLL <Entity.SysUser> bll     = new BLL.BaseBLL <Entity.SysUser>();
                List <BLL.FilterSearch>      filters = new List <BLL.FilterSearch>();
                filters.Add(new BLL.FilterSearch("UserName", viewModelLogin.user_name, BLL.FilterSearchContract.等于));
                filters.Add(new BLL.FilterSearch("Password", passworld, BLL.FilterSearchContract.等于));
                Entity.SysUser model = bll.GetModel(filters, null, "SysRole.SysRoleRoutes.SysRoute");
                if (model == null)
                {
                    ModelState.AddModelError("user_name", "用户名或密码错误");
                    return(View(viewModelLogin));
                }

                if (!model.Status)
                {
                    ModelState.AddModelError("user_name", "用户已被禁用");
                    return(View(viewModelLogin));
                }

                Session[SessionKey.Admin_User_Info] = model;
                Session.Timeout = 60;
                if (viewModelLogin.is_rember)
                {
                    WebHelper.SetCookie(CookieKey.Is_Remeber, "1", 14400);
                    WebHelper.SetCookie(CookieKey.Login_UserID, model.ID.ToString(), 14400);
                    WebHelper.SetCookie(CookieKey.Login_UserPassword, model.Password, 14400);
                }
                else
                {
                    WebHelper.SetCookie(CookieKey.Login_UserID, model.ID.ToString());
                    WebHelper.SetCookie(CookieKey.Login_UserPassword, model.Password);
                }
                model.LastLoginTime = DateTime.Now;
                bll.Modify(model, new string[] { "LastLoginTime" });
                AddAdminLogs(Entity.SysLogMethodType.Login, "通过后台网页登陆", model.ID);
                return(RedirectToAction("Index", "Home"));
            }


            return(View(viewModelLogin));
        }
Exemplo n.º 18
0
        public UserMemberInfo GetMemberInfoByPayPwd(long memid, string payPwd)
        {
            payPwd = payPwd.Trim();
            UserMemberInfo userMemberInfo = context.UserMemberInfo.FirstOrDefault((UserMemberInfo e) => e.Id == memid);

            if (userMemberInfo != null && SecureHelper.MD5(string.Concat(SecureHelper.MD5(payPwd), userMemberInfo.PayPwdSalt)) == userMemberInfo.PayPwd)
            {
                return(userMemberInfo);
            }
            return(null);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 更新指定门店管理员的密码
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="password"></param>
        public void UpdateShopBranchManagerPwd(long managerId, string password)
        {
            var branchManager = Context.ShopBranchManagersInfo.FirstOrDefault(e => e.Id == managerId);

            if (branchManager == null)
            {
                throw new Himall.Core.HimallException("数据异常,更新失败!");
            }

            branchManager.Password = SecureHelper.MD5(SecureHelper.MD5(password) + branchManager.PasswordSalt);
            Context.SaveChanges();
        }
Exemplo n.º 20
0
        public void SetPayPwd(long memid, string pwd)
        {
            pwd = pwd.Trim();
            string         str            = Guid.NewGuid().ToString("N");
            string         str1           = SecureHelper.MD5(string.Concat(SecureHelper.MD5(pwd), str));
            UserMemberInfo userMemberInfo = context.UserMemberInfo.FirstOrDefault((UserMemberInfo e) => e.Id == memid);

            if (userMemberInfo != null)
            {
                userMemberInfo.PayPwd     = str1;
                userMemberInfo.PayPwdSalt = str;
                context.SaveChanges();
            }
        }
Exemplo n.º 21
0
        public ActionResult User_Op(UserInfo user)
        {
            OperationResult result = null;
            var             old    = unitOfWork.DUserInfo.GetByID(user.ID);
            List <string>   list   = new List <string>();

            list.AddRange(this.Request.Form.AllKeys.AsEnumerable());
            string    uploadsFolder = Request.ApplicationPath.TrimEnd('/') + "/File/User/" + user.ID + "/";//附件路径文件
            MFileInfo fl            = new FileUploadService().FileUpload(uploadsFolder);

            if (fl != null)
            {
                user.Photo = fl.Path;
                list.Add("Photo");
            }
            string showpwd = user.Pwd;

            if (old == null)
            {
                user.uID        = Guid.NewGuid().ToString();
                user.States     = (int)Edu.Models.UserInfo_UserState.Normal;
                user.Pwd        = SecureHelper.MD5(showpwd);
                user.CreateDate = DateTime.Now;
                user.CreateUser = Edu.Service.LoginUserService.UserID.ToString();
                user.IPAdress   = Edu.Tools.StringHelper.GetIP();
                unitOfWork.DUserInfo.Insert(user);
                new DBLogService().insert(ActionClick.Add, user);
                result = unitOfWork.Save();
            }
            else
            {
                if (!string.IsNullOrEmpty(this.Request.Form["Pwd"]))
                {
                    user.Pwd = SecureHelper.MD5(showpwd);
                }
                new DBLogService().insert(ActionClick.Mody, user);
                unitOfWork.DUserInfo.Update(old, user, list);
                result = unitOfWork.Save();
                CacheHelper.RemoveAllCache("UserInfo" + old.ID);
            }
            if (result.ResultType == OperationResultType.Success)
            {
                return(Json(new { r = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { r = false, m = "操作失败\n" + result.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 在新增HiMall_Manager的时候给Shops表中加了一条数据,后面关于这条数据就都是修改(方法:CreateEmptyShop())
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        public ManagerInfo AddSellerManager(string username, string password, string salt = "")
        {
            ManagerInfo managerInfo;
            ManagerInfo managerInfo1 = context.ManagerInfo.FirstOrDefault((ManagerInfo p) => p.UserName == username);

            if (managerInfo1 != null)
            {
                return(new ManagerInfo()
                {
                    Id = managerInfo1.Id
                });
            }
            if (string.IsNullOrEmpty(salt))
            {
                Guid guid = Guid.NewGuid();
                salt = SecureHelper.MD5(guid.ToString("N"));
            }
            using (TransactionScope transactionScope = new TransactionScope())
            {
                ShopInfo shopInfo = Instance <IShopService> .Create.CreateEmptyShop();

                FieldCertification fieldfertification = Instance <ICertification> .Create.CreateFieldModulep();

                ManagerInfo managerInfo2 = new ManagerInfo()
                {
                    CreateDate   = DateTime.Now,
                    UserName     = username,
                    Password     = password,
                    PasswordSalt = salt,
                    ShopId       = shopInfo.Id,

                    CertificationId  = fieldfertification.Id,
                    SellerPrivileges = new List <SellerPrivilege>()
                    {
                        0
                    },
                    AdminPrivileges = new List <AdminPrivilege>(),
                    RoleId          = 0
                };

                managerInfo = managerInfo2;
                context.ManagerInfo.Add(managerInfo);
                context.SaveChanges();
                transactionScope.Complete();
            }
            return(managerInfo);
        }
Exemplo n.º 23
0
        public void EFDBContextTest()
        {
            var db = new EFDBContext();
            //编辑用户组
            //var role = db.SysRoles.Where(p => p.ID == 2).Include(s => s.SysRoleRoutes.Select(y => y.SysRoute)).FirstOrDefault();
            //添加测试路由
            //int[] power = { (int)DataCore.Entity.SysRouteType.add, (int)DataCore.Entity.SysRouteType.delete, (int)DataCore.Entity.SysRouteType.select };
            //int[] power2 = { (int)DataCore.Entity.SysRouteType.update, (int)DataCore.Entity.SysRouteType.upload };
            //var route1 = new DataCore.Entity.SysRoute() { AddTime = DateTime.Now, Desc = "测试路由", Route = "/home/index", Tag = "其他", RouteType = power };
            //var route2 = new DataCore.Entity.SysRoute() { AddTime = DateTime.Now, Desc = "测试路由2", Route = "/home/test", Tag = "其他2", RouteType = power2 };
            //db.SysRoutes.Add(route1);
            //db.SysRoutes.Add(route2);

            //添加组对应权限
            //var roleroute = new DataCore.Entity.SysRoleRoute() { SysRoleID = role.ID, SysRoute = route1 };
            //var roleroute2 = new DataCore.Entity.SysRoleRoute() { SysRoleID = role.ID, SysRoute = route2 };
            //db.SysRoleRoutes.Add(roleroute);
            //db.SysRoleRoutes.Add(roleroute2);

            //添加用户
            var    entity = db.SysRoles.Find(2);
            string pwd    = SecureHelper.MD5("admin");

            for (int i = 0; i < 30; i++)
            {
                var user = new Entity.SysUser()
                {
                    Avatar        = "",
                    Gender        = Entity.UserGender.男,
                    LastLoginTime = DateTime.Now,
                    NickName      = "编辑用户" + (i + 1).ToString(),
                    Password      = pwd,
                    RegTime       = DateTime.Now,
                    Status        = true,
                    SysRole       = entity,
                    UserName      = "******" + (i + 1).ToString()
                };
                db.SysUsers.Add(user);
            }

            db.SaveChanges();

            //var group = db.SysRoutes.GroupBy(p => p.Tag).ToList();

            db.Dispose();
            Assert.AreEqual(1, 1);
        }
Exemplo n.º 24
0
        public void ChangePlatformManagerPassword(long id, string password)
        {
            ManagerInfo managerInfo = context.ManagerInfo.FindBy((ManagerInfo item) => item.Id == id && item.ShopId == 0).FirstOrDefault();

            if (managerInfo == null)
            {
                throw new HimallException("该管理员不存在,或者已被删除!");
            }

            if (!string.IsNullOrWhiteSpace(password))
            {
                string str = SecureHelper.MD5(password);
                managerInfo.Password = SecureHelper.MD5(string.Concat(str, managerInfo.PasswordSalt));
            }
            context.SaveChanges();
            Cache.Remove(CacheKeyCollection.Manager(id));
        }
Exemplo n.º 25
0
        public JsonResult CheckOldPassword(string password)
        {
            IPaltManager currentManager = base.CurrentManager;
            string       str            = SecureHelper.MD5(string.Concat(SecureHelper.MD5(password), currentManager.PasswordSalt));

            if (currentManager.Password == str)
            {
                return(Json(new Result()
                {
                    success = true
                }));
            }
            return(Json(new Result()
            {
                success = false
            }));
        }
Exemplo n.º 26
0
        public JsonResult CheckOldPassword(string password)
        {
            var model = CurrentSellerManager;
            var pwd   = SecureHelper.MD5(SecureHelper.MD5(password) + model.PasswordSalt);

            if (model.Password == pwd)
            {
                return(Json(new Result()
                {
                    success = true
                }));
            }
            return(Json(new Result()
            {
                success = false
            }));
        }
Exemplo n.º 27
0
        public void AddPlatformManager(ManagerInfo model)
        {
            if (model.RoleId == 0)
            {
                throw new MallException("权限组选择不正确!");
            }
            if (CheckUserNameExist(model.UserName, true))
            {
                throw new MallException("该用户名已存在!");
            }
            model.ShopId       = 0;
            model.PasswordSalt = Guid.NewGuid().ToString();
            model.CreateDate   = DateTime.Now;
            var pwd = SecureHelper.MD5(model.Password);

            model.Password = SecureHelper.MD5(pwd + model.PasswordSalt);
            DbFactory.Default.Add(model);
        }
Exemplo n.º 28
0
        public ActionResult ModyPwd(UserInfo user)
        {
            OperationResult result = null;
            var             old    = unitOfWork.DUserInfo.GetByID(user.ID);

            old.PassWord = SecureHelper.MD5(user.PassWord);
            unitOfWork.DUserInfo.Update(old);
            result = unitOfWork.Save();

            if (result.ResultType == OperationResultType.Success)
            {
                return(Json(new { r = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { r = false, m = "操作失败\n" + result.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 29
0
        public bool AddSellerChild(UserMemberInfo memberInfo)
        {
            memberInfo.PasswordSalt = Guid.NewGuid().ToString();
            memberInfo.CreateDate   = DateTime.Now;
            string str = SecureHelper.MD5(memberInfo.Password);

            memberInfo.Password = SecureHelper.MD5(string.Concat(str, memberInfo.PasswordSalt));
            context.UserMemberInfo.Add(memberInfo);
            int i = context.SaveChanges();

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 30
0
        public void AddPlatformManager(ManagerInfo model)
        {
            if (model.RoleId == 0)
            {
                throw new HimallException("权限组选择不正确!");
            }
            if (CheckUserNameExist(model.UserName, true))
            {
                throw new HimallException("该用户名已存在!");
            }
            model.ShopId       = 0;
            model.PasswordSalt = Guid.NewGuid().ToString();
            model.CreateDate   = DateTime.Now;
            string str = SecureHelper.MD5(model.Password);

            model.Password = SecureHelper.MD5(string.Concat(str, model.PasswordSalt));
            context.ManagerInfo.Add(model);
            context.SaveChanges();
        }