Ejemplo n.º 1
0
        public ActionResult Register(UserInfo user)
        {
            if (CheckValidateCode())
            {
                IUserInfoService userInfoService = new UserInfoService();
                user.RoleID = 2;
                user.RegisterTime = DateTime.Now;
                user.NiCheng = user.LoginID;
                user.State = false;
                Random r = new Random();
                user.ActiCode = r.Next(100000, 1000000);
                UserInfo u = userInfoService.AddEntity(user);
                if (u != null)
                {
                    //注册成功 进行邮件验证  验证成功后才可登录
                    //使用LoginId跟Acticode进行验证

                    //return RedirectToAction("Index","Home");
                    //Response.Redirect()
                    //return View();
                    return Redirect("/Account/Verify");
                }
                else
                {
                    return Content("0");
                }
            }
            else
            {
                return Content("验证码错误");
            }
        }
Ejemplo n.º 2
0
 public void Add()
 {
     UserInfoService userInfoService=new UserInfoService();
     UserInfo userInfo = new UserInfo()
     {
         DeleteFlag = 1,Email = "[email protected]",
         LoginCode = "ypf",
         ModifiedDateTime = DateTime.Now,
         Password = "123123"
   ,
         Remark = "test data",
         SubmitDateTime = DateTime.Now,
         UserName = "yangpengfei",
         UserStatus = 1
     };
     Assert.AreEqual(true, userInfoService.Add(userInfo)); 
 }
        //权限判断业务逻辑
        protected virtual bool AuthorizeCore(ActionExecutingContext filterContext, bool isViewPage)
        {
            if (filterContext.HttpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }

            if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                return false;//判定用户是否登录
            }
            //获取当前用户信息
            UserInfo user = new UserInfo();
            UserInfoService _UserInfoService = new UserInfoService();
            user = _UserInfoService.GetKey((filterContext.HttpContext.User.Identity as FormsIdentity).Ticket.UserData.Split("|".ToCharArray())[0]);
            //var area = filterContext.RouteData.DataTokens["area"];
            //var controllerName = filterContext.RouteData.Values["controller"].ToString();
            //var actionName = filterContext.RouteData.Values["action"].ToString();
            if (isViewPage)//如果当前Action请求为具体的功能页并且不是MasterPage页
            {
                Predicate<SystemMenu> match = delegate(SystemMenu menu)
                {
                    if ((menu.Code.ToLower()) == area + "." + Controller + "." + Action)
                        return true;
                    else
                        return false;
                };
                SystemMenu has_menu = user.Role.Menu.Find(match);
                if (has_menu == null)
                    return false;

                //if (user.Role.Menu(m => m.ControllerName == controllerName && m.ActionName == actionName) == 0)
                //    return false;
            }
            else
            {
                //var actions = ContainerFactory.GetContainer().Resolve<IAuthorityFacade>().GetAllActionPermission();//所有被维护的Action权限
                //if (actions.Count(a => a.ControllerName == controllerName && a.ActionName == actionName) != 0)//如果当前Action属于被维护的Action权限
                //{
                //    if (user.ActionPermission.Count(a => a.ControllerName == controllerName && a.ActionName == actionName) == 0)
                //        return false;
                //}
            }
            return true;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public AccountController()
 {
     _UserInfoService = new UserInfoService();
     //_AccountService = new AccountService();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public HomeController()
 {
     _UserInfoService = new UserInfoService();
 }