Ejemplo n.º 1
0
 public ActionResult Login(string returnUrl)
 {
     var u = new SysUser();
     u.LogonName = "root";
     u.Password = "******";
     ViewData["returnUrl"] = returnUrl;
     return View(u);
     
 }
Ejemplo n.º 2
0
        public ActionResult Login(SysUser model,string returnUrl)
        {
            if (
                model.LogonName.Equals(WebUtils.GetAppSettingValue(StaticKey.AppSuperUserName))
                && model.Password.ToMd5().Equals(WebUtils.GetAppSettingValue("SuperUserPwd"))
                )
            {
                Session[StaticKey.IsSuper] = true;
                Session[StaticKey.SessionUser] = new SysUser() { 
                    LogonName = model.LogonName
                };
                if (!string.IsNullOrEmpty(returnUrl))
                    return Redirect(returnUrl);

                return RedirectToAction("index", "home");
            }
            else
            {
                var u = _uow.SysUserService.Get(t => t.LogonName == model.LogonName);
                if (u == null)
                {
                    TempData[StaticKey.TempGlobalError] = StaticKey.ErrorLogon;
                    return RedirectToAction("Login");
                }
                if(model.Password.ToMd5() != u.Password)
                {
                    TempData[StaticKey.TempGlobalError] = StaticKey.ErrorLogon;
                    return RedirectToAction("Login");
                }

                Session[StaticKey.SessionUser] = u;
                Session[StaticKey.SessionUserActionsList] =
                    _uow.GetUserActionList(u.Id).ToDictionary(t => t.ID);

                return RedirectToAction("index","home");

            }
            
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 创建新的 SysUser 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="logonName">LogonName 属性的初始值。</param>
 /// <param name="trueName">TrueName 属性的初始值。</param>
 /// <param name="password">Password 属性的初始值。</param>
 public static SysUser CreateSysUser(global::System.Int32 id, global::System.String logonName, global::System.String trueName, global::System.String password)
 {
     SysUser sysUser = new SysUser();
     sysUser.Id = id;
     sysUser.LogonName = logonName;
     sysUser.TrueName = trueName;
     sysUser.Password = password;
     return sysUser;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 用于向 SysUser EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSysUser(SysUser sysUser)
 {
     base.AddObject("SysUser", sysUser);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 用于向 SysUser EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSysUser(SysUser sysUser)
 {
     base.AddObject("SysUser", sysUser);
 }