예제 #1
0
        /// <summary>
        /// Action之前发生
        /// </summary>
        /// <param name="context"></param>
        public void OnActionExecuting(ActionExecutingContext context)
        {
            Sys_Account account = (Sys_Account)context.RouteData.Values["account"];

            if (account != null)
            {
                if (!account.IsSuperManage)
                {
                    var funcList = RegisterRoleMenu.funcList;
                    if (funcList != null && funcList.Count > 0)
                    {
                        var funcModel = funcList.Where(p => p.RoleMenuFunction_RoleID == account.RoleID && p.Menu_Num == _menu && _role.Contains(p.Function_ByName)).FirstOrDefault();
                        if (funcModel == null)
                        {
                            throw new MessageBox("您没有该功能的权限");
                        }
                    }
                    else
                    {
                        throw new MessageBox("您没有该功能的权限");
                    }
                }
            }
            else
            {
                throw new MessageBox("登陆超时,请重新登陆");
            }
        }
예제 #2
0
        public JsonResult UserLogin(string loginname, string password, string validateCode)
        {
            ResultMessage msg = new ResultMessage();

            try
            {
                if (!this.CheckValidateCode(validateCode, loginValidateCodeKey))
                {
                    throw new Exception("验证码错误");
                }
                IAccountCtrl accountCtrl = new AccountCtrl(null);
                bool         loginFlag   = accountCtrl.ValidAccount(loginname, password);
                if (loginFlag)
                {
                    Sys_Account account = accountCtrl.GetAccountByAccountName(loginname);
                    LoginAccount     = account;
                    msg.IsSuccess    = true;
                    msg.ErrorMessage = account.RoleList.SingleOrDefault().RoleType;
                }
                else
                {
                    msg.IsSuccess    = false;
                    msg.ErrorMessage = "登录失败:用户名或密码错误!";
                }
            }
            catch (Exception ex)
            {
                msg.IsSuccess    = false;
                msg.ErrorMessage = ex.Message;
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
 public RoleCtrl(Sys_Account account)
 {
     if (uow == null)
     {
         uow = new Uow();
     }
     loginAccount = account;
 }
예제 #4
0
 public CityCtrl(Sys_Account account)
 {
     if (uow == null)
     {
         uow = new Uow();
     }
     this.loginAccount = account;
 }
예제 #5
0
 public PageCtrl(Sys_Account account)
 {
     if (uow == null)
     {
         uow = new Uow();
     }
     this.account = account;
 }
예제 #6
0
 public SysBasicCity(Sys_Account account)
 {
     if (uow == null)
     {
         uow = new Uow();
     }
     loginAccount = account;
 }
예제 #7
0
        public JsonResult GetCityList()
        {
            Sys_Account   account  = this.LoginAccount as Sys_Account;
            ICityCtrl     cityCtrl = new CityCtrl(account);
            List <string> cityList = cityCtrl.GetCityList();

            return(Json(cityList, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        /// <summary>
        /// 左侧菜单
        /// </summary>
        /// <returns></returns>
        public string GetSysMenu(Sys_Account account)
        {
            _account = account;
            var           menu_list = this.GetMenuByRoleID();
            StringBuilder sb        = new StringBuilder();

            if (menu_list.Count > 0)
            {
                var parentList = menu_list.FindAll(item => item.Menu_ParentID == null || item.Menu_ParentID == "");
                var rolemenu   = new List <sys_rolemenufunction>();
                if (!account.IsSuperManage)
                {
                    rolemenu = (List <sys_rolemenufunction>)_Sys_RoleMenuFunctionRepository.FindListByClause(p => p.RoleMenuFunction_RoleID == account.RoleID && p.RoleMenuFunction_FunctionID == "C9518758-B2E1-4F51-B517-5282E273889C", "");
                }
                foreach (var item in parentList)
                {
                    var childList = menu_list.FindAll(w => w.Menu_ParentID != null && w.Menu_ParentID == item.Menu_ID);
                    if (childList.Count > 0)
                    {
                        //<li class="">
                        //<a class="has-first-menu has-arrow" href="#" aria-expanded="false"><i class=" fa fa-laptop"></i>&nbsp;&nbsp;<span>系统管理11133</span></a>
                        //</li>
                        sb.Append("<li>");
                        sb.Append(string.Format("<a class=\"has-arrow has-first-menu\" href=\"javascript:void(0)\" aria-expanded=\"false\"><i class=\"{0} fa-lg\"></i>&nbsp;&nbsp;<span>{1}</span></a>", item.Menu_Icon, item.Menu_Name));
                        GetChildMenu(menu_list, rolemenu, item.Menu_ID, sb);
                        sb.Append("</li>");
                    }
                    else
                    {
                        if (!account.IsSuperManage)
                        {
                            if (rolemenu.Find(p => p.RoleMenuFunction_MenuID == item.Menu_ID) == null)
                            {
                                continue;
                            }
                        }
                        //< li >
                        //            < a href = "#!/home1.html" >
                        //                 < i class="fa fa-fw fa-code-fork"></i>&nbsp;&nbsp;<span>测试1</span>
                        //              </a>
                        //        </li>
                        sb.Append("<li>");
                        if (!string.IsNullOrEmpty(item.Menu_Url))
                        {
                            sb.Append(string.Format("<a href=\"javascript:void(0);var url='{0}';\" hzy-router-href=\"{0}\" hzy-router-text=\"{2}\" class=\"has-first-menu\"><i class=\"{1}\"></i>&nbsp;&nbsp;<span>{2}</span></a>", item.Menu_Url, item.Menu_Icon, item.Menu_Name));
                        }
                        else
                        {
                            sb.Append(string.Format("<a href=\"javascript:void(0);\" hzy-router-text=\"{1}\" class=\"has-first-menu\"><i class=\"{0}\"></i>&nbsp;&nbsp;<span>{1}</span></a>", item.Menu_Icon, item.Menu_Name));
                        }
                        sb.Append("</li>");
                    }
                }
            }
            return(sb.ToString());
        }
 /// <summary>
 /// 检查当前登录用户是否有权限操作
 /// </summary>
 /// <param name="instance"></param>
 private void CheckPression(Sys_Account instance)
 {
     if (base.CurUserId != "administrator")
     {
         if (instance.User_Id == "administrator" || instance.User_Id == "test")
         {
             throw new Exception($"{instance.User_Id}是保留账户,你没有权限对其操作");
         }
     }
 }
예제 #10
0
        public UserAccountVM Login(string userId, string password)
        {
            Sys_Account account = _sysAccountD.FindSingle(m => m.Account == userId && m.Password == password);

            if (account == null)
            {
                throw new Exception("账号或密码错误");
            }
            //账号密码正确,查找各种权限组织
            UserAccountVM accountVM = new UserAccountVM();

            return(accountVM);
        }
예제 #11
0
        //修改密码
        public JsonResult ChangePwd(string oldPwd, string newPwd)
        {
            ResultMessage resultMessage = new ResultMessage();

            resultMessage.IsSuccess = true;
            try
            {
                Sys_Account  account     = LoginAccount as Sys_Account;
                IAccountCtrl accountCtrl = new AccountCtrl(account);
                accountCtrl.ChangePassword(oldPwd, newPwd);
                LogOut();
            }
            catch (Exception ex)
            {
                resultMessage.IsSuccess    = false;
                resultMessage.ErrorMessage = ex.Message;
            }
            return(Json(resultMessage, JsonRequestBehavior.AllowGet));
        }
        //GET: Remove Action GroupPermission
        public ActionResult Remove_GroupPermission(int id, string groupId)
        {
            Sys_GroupPermisionDetail detail = db.Sys_GroupPermisionDetail.Find(id);

            db.Sys_GroupPermisionDetail.Remove(detail);
            db.SaveChanges();

            // Update Session Authorize
            Sys_Account   user = (Sys_Account)Session["UserAccount"];
            List <string> lst  = (from a in db.Sys_Account
                                  join b in db.Sys_AccountPermission on a.Username equals b.Username
                                  join c in db.Sys_GroupPermisionDetail on b.GroupID equals c.GroupID
                                  where a.Username == user.Username
                                  select(c.Action_ID)).ToList();

            Session["UserAuthorize"] = lst;

            return(RedirectToAction("Edit", new { id = groupId }));
        }
예제 #13
0
        public ActionResult Login(Sys_Account Account)
        {
            var user = db.Sys_Account.FirstOrDefault(p => p.Username == Account.Username && p.Password == Account.Password);

            if (user != null)
            {
                List <string> lst = (from a in db.Sys_Account
                                     join b in db.Sys_AccountPermission on a.Username equals b.Username
                                     join c in db.Sys_GroupPermisionDetail on b.GroupID equals c.GroupID
                                     where a.Username == user.Username
                                     select(c.Action_ID)).ToList();

                Session["UserAuthorize"] = lst;

                Session["UserAccount"] = user;
                return(RedirectToAction("Index", "Home" /*, new { area = "Sys_HomePage" }*/));
            }

            return(RedirectToAction("Index", "Sys_Login"));
        }
예제 #14
0
        /// <summary>
        /// 创建缓存cookie
        /// </summary>
        /// <param name="user"></param>
        /// <param name="isRemember"></param>
        /// <returns></returns>
        protected virtual async Task <AjaxResult> CreateLoginResultAsync(Sys_Account user, bool isRemember)
        {
            //1:创建证件管理着
            ClaimsIdentity claimsIdentity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);

            //2:创建证件
            claimsIdentity.AddClaim(new Claim(ClaimTypes.Sid, user.Id.ToString()));
            claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, user.Account));

            //3:登陆
            _authenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            _authenticationManager.SignIn(new AuthenticationProperties()
            {
                IsPersistent = isRemember
            }, claimsIdentity);

            return(await Task.FromResult(AjaxResult.Ok(
                                             LoginPrompt.LoginSuccess
                                             )));
        }
예제 #15
0
        /// <summary>
        /// 新增加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Sys_Account model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_Account(");
            strSql.Append("accid,a_QQ,a_WeiXin,a_Tel,a_Address,a_Industry,a_Name,a_IdentityNumber,a_ShopSize,a_Operate,a_Duration,a_OtherSoftware,a_Remark,a_OtherSoftwareType,a_CustomerSourceType,a_CustomerSource,feedbackTel,feedbackQQ,a_UseCause,sysAddress");
            strSql.Append(") values (");
            strSql.Append("@accid,@a_QQ,@a_WeiXin,@a_Tel,@a_Address,@a_Industry,@a_Name,@a_IdentityNumber,@a_ShopSize,@a_Operate,@a_Duration,@a_OtherSoftware,@a_Remark,@a_OtherSoftwareType,@a_CustomerSourceType,@a_CustomerSource,@feedbackTel,@feedbackQQ,@a_UseCause,@sysAddress");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            object obj = DapperHelper.ExecuteScalar(strSql.ToString(), model);

            if (obj != null)
            {
                return(Convert.ToInt32(obj));
            }
            else
            {
                return(0);
            }
        }
        //GET: Add Action to GroupPermission
        public ActionResult AddAction_to_GroupPermission(string id, string GroupID)
        {
            Sys_GroupPermisionDetail groupPermission = new Sys_GroupPermisionDetail();

            groupPermission.GroupID   = GroupID;
            groupPermission.Action_ID = id;
            db.Sys_GroupPermisionDetail.Add(groupPermission);
            db.SaveChanges();

            // Update Session Authorize
            Sys_Account   user = (Sys_Account)Session["UserAccount"];
            List <string> lst  = (from a in db.Sys_Account
                                  join b in db.Sys_AccountPermission on a.Username equals b.Username
                                  join c in db.Sys_GroupPermisionDetail on b.GroupID equals c.GroupID
                                  where a.Username == user.Username
                                  select(c.Action_ID)).ToList();

            Session["UserAuthorize"] = lst;

            return(RedirectToAction("Edit", new { id = GroupID }));
        }
예제 #17
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Sys_Account model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_Account set ");

            strSql.Append(" accid = @accid , ");
            strSql.Append(" a_QQ = @a_QQ , ");
            strSql.Append(" a_WeiXin = @a_WeiXin , ");
            strSql.Append(" a_Tel = @a_Tel , ");
            strSql.Append(" a_Address = @a_Address , ");
            strSql.Append(" a_Industry = @a_Industry , ");
            strSql.Append(" a_Name = @a_Name , ");
            strSql.Append(" a_IdentityNumber = @a_IdentityNumber , ");
            strSql.Append(" a_ShopSize = @a_ShopSize , ");
            strSql.Append(" a_Operate = @a_Operate , ");
            strSql.Append(" a_Duration = @a_Duration , ");
            strSql.Append(" a_OtherSoftware = @a_OtherSoftware , ");
            strSql.Append(" a_Remark = @a_Remark , ");
            strSql.Append(" a_OtherSoftwareType = @a_OtherSoftwareType , ");
            strSql.Append(" a_CustomerSourceType = @a_CustomerSourceType , ");
            strSql.Append(" a_CustomerSource = @a_CustomerSource , ");
            strSql.Append(" feedbackTel = @feedbackTel , ");
            strSql.Append(" feedbackQQ = @feedbackQQ , ");
            strSql.Append(" a_UseCause = @a_UseCause , ");
            strSql.Append(" sysAddress = @sysAddress  ");
            strSql.Append(" where id=@id ");

            int row = DapperHelper.Execute(strSql.ToString(), model);

            if (row > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #18
0
        /// <summary>
        /// 登陆验证
        /// </summary>
        /// <param name="account"></param>
        /// <param name="plainPassword"></param>
        /// <param name="isRemember"></param>
        /// <returns></returns>
        protected virtual async Task <AjaxResult> LoginAsyncInternal(string account, string plainPassword, bool isRemember)
        {
            if (account.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(account));
            }

            if (plainPassword.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(plainPassword));
            }


            Sys_Account user = await _accountRepository.FirstOrDefaultAsync(u => u.Account.Equals(account));

            //1.检查人员是否存在
            if (user == null)
            {
                return(AjaxResult.Fail(LoginPrompt.AccountNotExisit));
            }
            //2.账号未被激活
            if (!user.IsActive)
            {
                return(AjaxResult.Fail(LoginPrompt.DisableAccount));
            }
            //3.检查密码是否正常
            if (user.Password != plainPassword)
            {
                return(AjaxResult.Fail(LoginPrompt.PwdError));
            }
            //3.检查账户是否有授权

            if (await userRoleRepository.FirstOrDefaultAsync(u => u.UserId.Equals(user.Id)) == null)
            {
                return(AjaxResult.Fail(LoginPrompt.NoGrant));
            }

            return(await CreateLoginResultAsync(user, isRemember));
        }
예제 #19
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Sys_Account model)
        {
            Sys_AccountBaseDAL dal = new Sys_AccountBaseDAL();

            return(dal.Update(model));
        }
예제 #20
0
        /// <summary>
        /// 新增加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Add(Sys_Account model)
        {
            Sys_AccountBaseDAL dal = new Sys_AccountBaseDAL();

            return(dal.Add(model));
        }