Beispiel #1
0
        public ActionResult Login(Panasia.Gemini.FL.Models.LoginModel model)
        {
            System.Data.DataSet dsLoginInfo = new Data.Common.sys_User().Login(model.UserName, GetMd5_32(model.Password));
            if (dsLoginInfo != null && dsLoginInfo.Tables[0].Rows.Count == 1)
            {
                HttpCookie          login = new HttpCookie("login");
                System.Data.DataRow row   = dsLoginInfo.Tables[0].Rows[0];
                foreach (System.Data.DataColumn col in dsLoginInfo.Tables[0].Columns)
                {
                    login.Values.Add(col.ColumnName, HttpUtility.UrlEncode(row[col.ColumnName].ToString()));
                }

                login.Expires = DateTime.Now.AddDays(1);
                Response.Cookies.Add(login);

                Response.Redirect("~/");
            }
            else
            {
                ViewBag.LoginError = true;
            }
            //if (ValidateUser(model.UserName, model.Password))
            //{
            //    QX(model.UserName);
            //    return RedirectToAction("Rc006", "Interview_Info");
            //}
            return(View("Fl000"));
        }
Beispiel #2
0
        public ActionResult Login(Panasia.Gemini.FL.Models.LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var loginModel = new LoginViewModel {
                    UserName = model.UserName, Password = model.Password
                };

                if (!loginModel.WebLogin(false))
                {
                    ModelState.AddModelError("", Messages.System_InvalidUserNameOrPassword);
                    this.AddSystemLog("登录失败", "Account/Login", Messages.System_InvalidUserNameOrPassword, model.UserName);
                    return(View(model));
                }
                else
                {
                    UserSession session = new UserSession();
                    session.UserModel      = SysService.GetUserModel(model.UserName);
                    session.Roles          = SysService.GetRoles();
                    Session["userSession"] = session;
                    this.AddSystemLog("登录成功", "Account/Login", "UserName:"******"login");
                        System.Data.DataRow row   = dsLoginInfo.Tables[0].Rows[0];
                        foreach (System.Data.DataColumn col in dsLoginInfo.Tables[0].Columns)
                        {
                            login.Values.Add(col.ColumnName, HttpUtility.UrlEncode(row[col.ColumnName].ToString()));
                        }

                        login.Expires = DateTime.Now.AddDays(1);
                        Response.Cookies.Add(login);

                        Response.Redirect("~/");
                    }
                    else
                    {
                        ViewBag.LoginError = true;
                    }
                    return(null);
                }
            }

            //if (ValidateUser(model.UserName, model.Password))
            //{
            //    QX(model.UserName);
            //    return RedirectToAction("Rc006", "Interview_Info");
            //}
            return(View("Fl000"));
        }