示例#1
0
        public ActionResult Regist(RegistModel model)
        {
            var request = _container.Resolve <RegistRequest>();

            request.Set(model);
            return(Json(request.Save()));
        }
        public JsonResponse MemberLogin([FromBody] JsonRequest model)
        {
            try
            {
                RegistModel item = model.Data.ToString()?.DeserialObject <RegistModel>();

                if (string.IsNullOrEmpty(item.UserAccount) || string.IsNullOrEmpty(item.UserPassword))
                {
                    return(new JsonResponse {
                        Code = 1, Msg = "参数不合法"
                    });
                }

                var res = BlogHelper.MemberLogin(item.UserAccount, item.UserPassword, "0", UtilConst.GetIP(), "", "");
                if (res != null && res.IsSucceed)
                {
                    res.MemberInfo.UserPassword = "";
                }

                return(new JsonResponse {
                    Code = res.IsSucceed ? 0 : 1, Msg = res.Message, Data = res
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex, "MemberController/RegistItemMember");
                return(new JsonResponse {
                    Code = 1, Msg = "程序好像开小差了" + ex
                });
            }
        }
示例#3
0
        public async Task <IActionResult> SignUp(RegistModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await _context.Users.FirstOrDefaultAsync(u => u.Login == model.Login);

                if (user == null)
                {
                    model.Password = Seed.HashingPassword(model.Password);
                    Guid id   = Guid.NewGuid();
                    var  role = await _context.Roles.FirstAsync(p => p.RoleText == "Client");

                    _context.Users.Add(new User()
                    {
                        Id         = id.ToString(),
                        FirstName  = model.FirstName,
                        LastName   = model.LastName,
                        Login      = model.Login,
                        MiddleName = model.MiddleName,
                        Password   = model.Password,
                        Role       = role
                    });
                    await _context.SaveChangesAsync();
                    await Authentucate(model.Login, role.RoleText);

                    return(RedirectToAction("Index", "Home", new { @area = "" }));
                }
                ModelState.AddModelError("", "This login being using!");
            }
            return(View(model));
        }
示例#4
0
        public UserModel Regist(RegistModel registModel)
        {
            var user = mapper.Map <UserDto>(registModel);

            user = userRepository.Insert(user);
            return(mapper.Map <UserModel>(user));
        }
示例#5
0
        public async Task <IActionResult> Registered(RegistModel model)
        {
            var Res = new ServiceResult();

            if (!model.Password.Equals(model.CPassword))
            {
                Res.IsFailed("密码不一样,请检查");
                return(Ok(Res));
            }
            var loginModel = await _userAppService.CheckUser(model.Name, model.Password);

            if (loginModel != null)
            {
                Res.IsFailed("用户名或者邮箱已经存在");
                return(Ok(Res));
            }
            bool IsOK = await _userAppService.Add(new User()
            {
                EMail = model.Email, UserName = model.Name, Password = model.Password, DeptmentId = Guid.Empty
            });

            if (IsOK)
            {
                Res.IsSuccess("注册成功");
            }
            else
            {
                Res.IsFailed("注册失败");
            }

            return(Ok(Res));
        }
示例#6
0
        public void createViewRegist()
        {
            _view = new LoginView();
            RegistView       _viewRegist  = new RegistView();
            RegistModel      _modelRegist = new RegistModel();
            RegistController _ctrlRegist  = new RegistController(_modelRegist, _viewRegist);

            _ctrlRegist.CreateView();
            _flag = true;
        }
示例#7
0
        //public class RegistModel
        //{
        //    public string Username { get; set; }
        //    public string Password { get; set; }
        //    public string NickName { get; set; }
        //    public Gender Gender { get; set; }
        //    public int Age { get; set; }
        //    public string EMail { get; set; }
        //    public string PhoneNumber { get; set; }
        //}

        public async Task RegistAsync(HttpBaseService httpService, RegistModel model)
        {
            try
            {
                var passwordHash = Helpers.Utility.GetMD5(model.Password);
                var dic          = new Dictionary <string, string>();
                dic.Add("Username", model.Username);
                dic.Add("Password", passwordHash);
                dic.Add("Nickname", model.NickName);
                dic.Add("Gender", model.Gender.ToString());
                dic.Add("Age", model.Age.ToString());
                dic.Add("College", model.College.ToString());

                var re = await httpService.SendRequst(registUri, HttpMethod.Post, dic);

                if (string.IsNullOrEmpty(re))
                {
                    throw new LoginTipException("服务故障");
                }
                var resultModel = Newtonsoft.Json.JsonConvert.DeserializeObject <RegistResultModel>(re);
                if (resultModel == null)
                {
                    throw new LoginTipException("服务故障");
                }
                switch (resultModel.Code)
                {
                case 200:
                    break;

                case 300:
                    throw new LoginTipException("该用户名已经注册");

                case 400:
                    throw new LoginTipException("注册信息填写错误");

                case 500:
                    throw new LoginTipException("服务故障");

                default:
                    throw new LoginTipException($"未知异常 Code:{resultModel.Code}");
                }
            }
            catch (HttpRequestException)
            {
                throw new LoginTipException("服务故障");
            }
            catch
            {
                throw;
            }
        }
示例#8
0
        public ActionResult RegistAdd(RegistModel model)
        {
            string msg = "";

            if (this._iCustomerService.GetEntityByName(model.UserName) != null)
            {
                msg = "此用户已存在";

                ViewBag.msg = msg;
                return(View("Regist"));
            }
            if (this._iCustomerService.GetCustomerByMobile(model.Moblie) != null)
            {
                msg = "此手机号已注册";

                ViewBag.msg = msg;
                return(View("Regist"));
            }
            Customer cs = new Customer();

            cs.Name         = model.UserName;
            cs.LoginName    = model.UserName;
            cs.Password     = model.Password;
            cs.Mobile       = model.Moblie;
            cs.GroupId      = (int)YG.SC.Common.CommonEnum.GroupOfCustomer.Member;
            cs.Online       = true;
            cs.Property     = model.Property == "个人" ? false : true;
            cs.registertime = DateTime.Now;

            this._iCustomerService.Insert(cs);
            var    entity     = this._iCustomerService.GetEntityByNameAndPassword(cs.Mobile, cs.Password);
            string rememberMe = "";

            WriteUserSession(entity, rememberMe);
            if (entity.GroupId == (int)YG.SC.Common.CommonEnum.GroupOfCustomer.OpenShop)
            {
                return(Redirect("~/Merchant/Company_index/" + entity.Companyid));
            }
            else
            {
                return(Redirect("~/Customer/Memberindex/" + entity.Companyid));
            }
        }
示例#9
0
 public RegistController(RegistModel model, RegistView view)
 {
     this._model = model;
     this._view  = view;
 }