コード例 #1
0
 public void UserInfoUpdate(FormCollection form)
 {
     Web.Models.UserCenter.UserInfoUpdateModel viewModel = new Models.UserCenter.UserInfoUpdateModel();
     viewModel.UserName = form["txtUserName"] ?? "";
     viewModel.Email    = form["txtEmail"] ?? "";
     viewModel.Pwd      = form["txtPwd"] ?? "";
     ValidateModel(viewModel);
     XCLShouCang.BLL.v_UserInfo vBLL  = new XCLShouCang.BLL.v_UserInfo();
     XCLShouCang.BLL.UserInfo   bll   = new XCLShouCang.BLL.UserInfo();
     XCLShouCang.Model.UserInfo model = bll.GetModel(base.CurrentUserModel.UserID);
     model.Email    = viewModel.Email;
     model.UserName = viewModel.UserName;
     if (!string.Equals(viewModel.UserName, base.CurrentUserModel.UserName, StringComparison.CurrentCultureIgnoreCase) && bll.IsExists(viewModel.UserName))
     {
         XCLNetTools.Message.Log.WriteMessage("该用户名已被占用,修改失败!");
         return;
     }
     if (!string.IsNullOrEmpty(viewModel.Pwd))
     {
         model.Pwd = XCLNetTools.StringHander.StringUtil.str_md5(viewModel.Pwd);
     }
     model.UpdateName = base.CurrentUserModel.UserName;
     model.UpdateTime = DateTime.Now;
     if (bll.Update(model))
     {
         base.SetLogInfo(1, model);
         XCLNetTools.Message.Log.WriteMessage("修改成功!");
     }
     else
     {
         XCLNetTools.Message.Log.WriteMessage("修改失败,请重试!");
     }
 }
コード例 #2
0
        public void LogOnSubmit(FormCollection form)
        {
            try
            {
                XCLShouCang.BLL.UserInfo   bll       = new XCLShouCang.BLL.UserInfo();
                XCLShouCang.Model.UserInfo model     = new XCLShouCang.Model.UserInfo();
                Models.Login.LogOnModel    viewModel = new Models.Login.LogOnModel();
                viewModel.UserName = (form["txtUserName"] ?? "").Trim();
                viewModel.Pwd      = form["txtPwd"];
                ValidateModel(viewModel);
                if (bll.IsExists(viewModel.UserName, XCLNetTools.StringHander.StringUtil.str_md5(viewModel.Pwd)))
                {
                    var userInfo = bll.GetModel(viewModel.UserName);
                    base.SetLogInfo(1, userInfo);

                    XCLNetTools.Message.MessageModel msgModel = new XCLNetTools.Message.MessageModel()
                    {
                        IsRefresh = true,
                        IsSuccess = true,
                        Message   = "登录成功!"
                    };
                    XCLNetTools.Message.Log.WriteMessage(msgModel);
                }
                else
                {
                    XCLNetTools.Message.Log.WriteMessage("用户名或密码错误!");
                }
            }
            catch
            {
                XCLNetTools.Message.Log.WriteMessage("登录失败,请重试!");
            }
        }
コード例 #3
0
        /// <summary>
        /// 每个action之前登录操作
        /// </summary>
        private void LogOn()
        {
            //先判断在session中存不存在,若不存在,则重新使用cookie进行登录。
            XCLShouCang.Model.UserInfo tempUserModel = Session[BaseController.CurrentUserModelSessionName] as XCLShouCang.Model.UserInfo;
            if (null != tempUserModel)
            {
                return;
            }

            string userInfoCookie = XCLNetTools.StringHander.Common.GetCookies(BaseController.UserLoginCookieName);

            userInfoCookie = string.IsNullOrEmpty(userInfoCookie) ? Convert.ToString(Session[BaseController.UserLoginCookieName]) : userInfoCookie;

            if (!string.IsNullOrEmpty(userInfoCookie))
            {
                string userInfo = "";
                try
                {
                    userInfo = XCLNetTools.StringHander.DESEncrypt.Decrypt(userInfoCookie);
                    if (!string.IsNullOrEmpty(userInfo))
                    {
                        string[] userArr = userInfo.Split('|');
                        if (null != userArr && userArr.Length == 2)
                        {
                            XCLShouCang.BLL.UserInfo    bll        = new XCLShouCang.BLL.UserInfo();
                            Web.Models.Login.LogOnModel logOnModel = new Models.Login.LogOnModel();
                            logOnModel.UserName = userArr[0];
                            logOnModel.Pwd      = userArr[1];
                            if (bll.IsExists(logOnModel.UserName, logOnModel.Pwd))
                            {
                                this.CurrentUserModel = bll.GetModel(logOnModel.UserName);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #4
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));
        }