예제 #1
0
        // GET: /F2/LoginOk?uid=panda&return_url=http://52xyj.cn&msg=测试
        public ActionResult LoginOk(string uid, string return_url, string msg = "", string uName = "未设置")
        {
            var accountContext = new AccountContext();

            //DataContext.UserId =
            //    accountContext.UserID = uid;
            //DataContext.UserName =
            // accountContext.UserName = uName;
            DataContext = new DataContext(HttpContext, uid, "", uName);
            Session["AccountContext"] = accountContext;
            if (return_url.HasValue())
            {
                //加入参数
                return_url += (return_url.Contains("?") ? "&" : "?") + "uid=" + uid + "&msg=" + msg;
                return(Redirect(return_url));
            }
            else if (ReturnUrl.HasValue() && ReturnUrl != "/" && !return_url.ToLower().Contains("login"))
            {
                return(Redirect(ReturnUrl));
            }
            else
            {
                return(RedirectToAction("Index", new { msg = "用户[" + uid + "]登录成功!" }));
            }
        }
        public ActionResult Regist(Regist_M model)
        {
            model.UserId   = F("UserId");
            model.UserPsw  = F("UserPsw"); model.UserPsw2 = F("UserPsw2");
            model.NickName = F("NickName");
            model.Phone    = F("Phone");
            model.Email    = F("Email");

            if (model.UserPsw != model.UserPsw2 ||
                !model.UserPsw.HasValue() ||
                !model.UserPsw2.HasValue())
            {
                return(Alert("两次密码不一致!", -1));
            }

            if (!model.UserId.HasValue() ||
                !model.NickName.HasValue())
            {
                return(Alert("注册信息不完整!", -1));
            }



            if (ModelState.IsValid)
            {
                if (_permissionProvider.Regist(model.UserId, model.UserPsw,
                                               model.NickName, model.Email, model.Phone
                                               ))
                {
                    var accountContext = new AccountContext();
                    DataContext.UserID        =
                        accountContext.UserID = model.UserId;
                    DataContext.UserUnit      = "1577668579";
                    Session["AccountContext"] = accountContext;
                    if (ReturnUrl.HasValue())
                    {
                        return(Redirect(ReturnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", new { msg = "用户[" + model.UserId + "]登录成功!" }));
                    }
                }
                else
                {
                    return(Alert("注册失败!", -1));
                }
            }
            else
            {
                return(View(model));
            }
        }
        // GET: /Account/LoginOk?uid=panda&return_url=http://52xyj.cn&msg=测试
        public ActionResult LoginOk(string uid, string return_url, string msg = "", string uName = "未设置")
        {
            var accountContext = new AccountContext();

            DataContext.UserID          =
                accountContext.UserID   = uid;
            DataContext.UserName        =
                accountContext.UserName = uName;
            Session["AccountContext"]   = accountContext;
            if (return_url.HasValue())
            {
                return(Redirect(return_url));
            }
            else if (ReturnUrl.HasValue())
            {
                return(Redirect(ReturnUrl));
            }
            else
            {
                return(RedirectToAction("Index", new { msg = "用户[" + uid + "]登录成功!" }));
            }
        }