Exemplo n.º 1
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"));
        }
Exemplo n.º 2
0
        public ActionResult UserRole(string ID)
        {
            var           userRole = SysService.GetUserRoles(ID);
            UserAuthModel model    = new UserAuthModel {
                UserID = ID, Roles = new List <AuthRoleModel>()
            };

            foreach (var r in SysService.GetRoles("", ""))
            {
                model.Roles.Add(new AuthRoleModel
                {
                    RoleID     = r.RoleID,
                    Name       = r.Name,
                    IsSelected = userRole.FirstOrDefault(f => f.Equals(r.RoleID)) != null
                });
            }
            return(View(model));
        }
Exemplo n.º 3
0
 public ActionResult Login(LoginViewModel model, string ReturnUrl = "")
 {
     if (ModelState.IsValid)
     {
         if (!model.WebLogin())
         {
             ModelState.AddModelError("", Messages.System_InvalidUserNameOrPassword);
             this.AddSystemLog("登录失败", "Account/Login", Messages.System_InvalidUserNameOrPassword, model.UserName);
         }
         else
         {
             UserSession session = new UserSession();
             session.UserModel      = SysService.GetUserModel(model.UserName);
             session.Roles          = SysService.GetRoles();
             Session["userSession"] = session;
             this.AddSystemLog("登录成功", "Account/Login", "UserName:" + model.UserName, session.UserModel.FullName);
             return(null);
         }
     }
     return(View(model));
 }