Exemple #1
0
        public AccessTokenResult Register(string mobile, string code, string password, string ip, string from)
        {
            ExceptionHelper.ThrowIfNullOrWhiteSpace(from, "from", "注册来源不能为空");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyPassword(password), "password", "密码格式错误");
            _MobileManager.Verify(code, mobile, ValidateType.登陆);
            var areaNo = "0001";
            var area   = _StaticResourceManager.GetIPArea(ip);

            if (area != null)
            {
                areaNo = area.area_no;
            }
            long uid;

            using (var service = _UserManagerServiceChannelProvider.NewChannelProvider())
            {
                uid = service.Channel.GetUidIfNonexistentRegister(new OAuth2ClientIdentity(), mobile, true, password, ip, from);
            }
            ExceptionHelper.ThrowIfTrue(uid <= 0, "uid", "创建用户失败");
            var securityPsw = string.Empty;

            using (var provider = _UserManagerServiceChannelProvider.NewChannelProvider())
            {
                var id = Tgnet.Security.NumberConfuse.Confuse(uid);
                securityPsw = provider.Channel.GetPassword(new OAuth2ClientIdentity(), id);
            }
            if (!_UserRepository.Entities.Any(p => p.uid == uid))
            {
                _UserRepository.Add(new FootUser()
                {
                    mobile     = mobile,
                    uid        = uid,
                    password   = securityPsw,
                    areaNo     = areaNo,
                    isInner    = false,
                    isLocked   = false,
                    loginCount = 1,
                    lastLogin  = DateTime.Now,


                    created      = DateTime.Now,
                    verifyImage  = String.Empty,
                    verifyStatus = VerifyStatus.None,
                    cover        = "",
                });
                _UserRepository.SaveChanges();
                //推送到图数据库
                var taskFactory = new TaskFactory();
                taskFactory.StartNew(() =>
                {
                    _PushManager.AddUser(uid, mobile, false);
                });
            }
            return(VerificationCodeLogin(mobile, code, ip));
        }
Exemple #2
0
        public IUserService Register(IRegisterInfo info)
        {
            ExceptionHelper.ThrowIfNull(info, "info");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(info.Mobile), "mobile", "手机格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyEmail(info.Email), "email", "邮箱格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyPassword(info.Password), "password", "密码格式不正确,密码长度为6-20位");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Name, "name", "名称不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Company, "company", "公司不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.AreaNo, "areaNo", "没有选择地区");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Address, "address", "地址不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.IndustryNo, "industryNo", "没有选择行业类别");

            ExceptionHelper.ThrowIfTrue(!IsUsableMobile(info.Mobile), "mobile", "此手机号已经被注册");
            ExceptionHelper.ThrowIfTrue(!IsUsableEmail(info.Email), "email", "此邮箱已经被注册");
            using (var scope = new System.Transactions.TransactionScope())
            {
                _MobileManager.Verify(info.Code, info.Mobile);
                var entity = new Data.User
                {
                    address              = info.Address.SafeTrim(),
                    area_no              = info.AreaNo.SafeTrim(),
                    industry_no          = info.IndustryNo.SafeTrim(),
                    company              = info.Company.Trim(),
                    email                = info.Email.Trim(),
                    employees_count_type = info.EmployeesCountRange,
                    is_purchaser         = info.IsPurchaser,
                    mobile               = info.Mobile.Trim(),
                    name            = info.Name.Trim(),
                    neet_invoice    = info.NeetInvoice,
                    tel             = info.Tel == null ? null : info.Tel.Trim(),
                    pwd             = new Security.MD5().Encrypt(info.Password.Trim()),
                    last_login_date = DateTime.Now,
                    register_date   = DateTime.Now,
                    enabled         = true,
                };
                _UserRepository.Add(entity);
                _UserRepository.SaveChanges();
                scope.Complete();

                return(GetUser(entity));
            }
        }
Exemple #3
0
 public ActionResult VerifyCode(string mobile, string code)
 {
     _MobileManager.Verify(code, mobile);
     Session.SetCurrentVerifyMobile(mobile);
     return(SuccessJsonResult());
 }