Ejemplo n.º 1
0
        public async Task <ActionResult <UserSignUpResponse> > SignUpManager([FromBody] UserSignUpRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var result = await _registrationService.RegisterManagerAsync(request.Email, request.Password);

            var response = new UserSignUpResponse
            {
                Email = request.Email,
                Role  = ApplicationRoles.Manager,
                IsRegistrationSuccessful = result
            };

            if (result)
            {
                return(response);
            }

            response.ResponseException = "Not successful registration. Check logs";

            return(response);
        }
Ejemplo n.º 2
0
        public UserSignUpResponse UserSignUp([FromBody] UserSignUpRequest req)
        {
            var time = DateTime.Now;
            var rep  = new UserSignUpResponse();

            if (!req.Mobile.IsMobile())
            {
                rep.Error("请输入正确的手机号码");
                return(rep);
            }
            if (!req.Pwd.IsPassword())
            {
                rep.Error("密码为6-18个字符(至少包含两个字母、两个数字、一个特殊字符)");
                return(rep);
            }

            var valid = ValidateSmsCaptcha(req.Guid, req.Mobile, req.Captcha);

            if (!valid)
            {
                rep.Error("短信验证码不正确或已过期");
                return(rep);
            }

            var userId = DefaultStorage.UserIdGet(req.Uid);

            if (userId > 0)
            {
                rep.Error("该手机号码已被使用,请换一个");
                return(rep);
            }
            var pwd = req.Pwd;

            var user    = new User();
            var profile = new UserProfile();

            //var extra = new UserExtra();

            user.Guid     = Guid.NewGuid().ToString();
            user.Name     = req.Uid;
            user.Email    = string.Empty;
            user.Mobile   = req.Mobile;
            user.Nickname = string.Empty;
            user.Password = pwd;

            user.Role       = UserRole.Buyer;
            user.Grade      = UserGrade.None;
            user.Limitation = UserLimitation.None;
            user.Permission = UserPermission.None;

            user.Avatar = string.Empty;
            user.Status = UserStatus.Normal;

            user.AuthedOn   = null;
            user.CreatedBy  = string.Empty;
            user.CreatedOn  = time;
            user.ModifiedBy = string.Empty;
            user.ModifiedOn = time;

            profile.Code     = string.Empty;
            profile.Name     = string.Empty;
            profile.Gender   = Gender.Secrect;
            profile.Marital  = Marital.Secrect;
            profile.Birthday = null;
            profile.Phone    = string.Empty;
            profile.Mobile   = string.Empty;
            profile.RegionId = string.Empty;
            profile.Street   = string.Empty;

            profile.SignUpIp     = string.Empty;
            profile.SignUpBy     = 1;
            profile.TraceCode    = "";
            profile.LastSignInIp = string.Empty;
            profile.LastSignInOn = time;

            user.Profile = profile;
            //user.Extra = extra;

            var id = DefaultStorage.UserCreate(user);

            if (id > 0)
            {
                rep.Data = DefaultStorage.UserGet(id);
            }
            else
            {
                rep.Error("注册失败,请稍后再试");
                return(rep);
            }

            return(rep);
        }