예제 #1
0
 public void RegisterSubmit(FormCollection form)
 {
     XCLShouCang.BLL.UserInfo   bll       = new XCLShouCang.BLL.UserInfo();
     XCLShouCang.Model.UserInfo model     = new XCLShouCang.Model.UserInfo();
     Models.Login.RegisterModel viewModel = new Models.Login.RegisterModel();
     viewModel.UserName   = (form["txtUserName"] ?? "").Trim();
     viewModel.Pwd        = form["txtPwd"] ?? "";
     viewModel.ConfirmPwd = form["txtConfirmPwd"];
     viewModel.Email      = (form["txtEmail"] ?? "").Trim();
     ValidateModel(viewModel);
     model.UserName = viewModel.UserName;
     model.Email    = viewModel.Email;
     model.Pwd      = XCLNetTools.StringHander.StringUtil.str_md5(viewModel.Pwd);
     if (bll.AddUserInfo(model) > 0)
     {
         XCLNetTools.Message.Log.WriteMessage(string.Format(@"恭喜您,注册成功!<a href=""{0}"">【马上登录】</a>", Url.Action("Index", "Login")));
     }
     else
     {
         XCLNetTools.Message.Log.WriteMessage("注册失败,请重试!");
     }
 }
예제 #2
0
        public ActionResult LoginByThird()
        {
            string thirdLoginType  = XCLNetTools.StringHander.FormHelper.GetString("ThirdLoginType");
            string thirdLoginToken = XCLNetTools.StringHander.FormHelper.GetString("ThirdLoginToken");
            string nickName        = XCLNetTools.StringHander.FormHelper.GetString("NickName");

            XCLNetTools.Message.MessageModel msgModel = new XCLNetTools.Message.MessageModel();
            if (!string.IsNullOrEmpty(thirdLoginType) && !string.IsNullOrEmpty(thirdLoginToken))
            {
                XCLShouCang.BLL.UserInfo   bll    = new XCLShouCang.BLL.UserInfo();
                XCLShouCang.Model.UserInfo uModel = null;
                if (bll.IsExistsThirdLogin(thirdLoginType, thirdLoginToken))
                {
                    //使用该账号
                    uModel = bll.GetModelByThirdLogin(thirdLoginType, thirdLoginToken);
                    base.SetLogInfo(1, uModel);
                    msgModel.IsSuccess = true;
                }
                else
                {
                    //系统自动创建新账号
                    uModel                 = new XCLShouCang.Model.UserInfo();
                    uModel.UserName        = XCLNetTools.StringHander.RandomHelper.GenerateStringId();
                    uModel.NickName        = nickName;
                    uModel.ThirdLoginToken = thirdLoginToken;
                    uModel.ThirdLoginType  = thirdLoginType;
                    long resultID = bll.AddUserInfo(uModel);
                    if (resultID > 0)
                    {
                        base.SetLogInfo(1, bll.GetModel(resultID));
                        msgModel.IsSuccess = true;
                    }
                }
            }
            return(Json(msgModel));
        }