public override void OnActionExecuting(SWM.ActionExecutingContext filterContext)
        {
            if (HttpContext.Current.Session[SessionKeys.MemberInfo] == null)
            {
                IMemberBusiness memberBusiness = (IMemberBusiness)SWM.DependencyResolver.Current.GetService(typeof(IMemberBusiness));

                var httpCookie = HttpContext.Current.Request.Cookies[SessionKeys.CookiePrefix];

                if (httpCookie != null && httpCookie.Values[SessionKeys.Cookie_MemberId] != null)
                {
                    string value = httpCookie.Values[SessionKeys.Cookie_MemberId];
                    CrpytorEngine crp = new CrpytorEngine() { SecurityKey = SessionKeys.Cookie_MemberId };

                    var memberId = int.Parse(crp.Decrypt(value, true));

                    var resultSet = memberBusiness.GetMemberByMemberId(memberId);
                    if (resultSet.Success)
                    {
                        HttpContext.Current.Session[SessionKeys.MemberInfo] = new SessionUser()
                        {
                            Id = resultSet.Object.Id,
                            NickName = resultSet.Object.NickName,
                            Name = resultSet.Object.Name,
                            SurName = resultSet.Object.Surname
                        };
                    }
                }
            }
            if (HttpContext.Current.Session[SessionKeys.MemberInfo] == null)
                filterContext.Result = new SWM.RedirectResult(string.Format("/{0}/{1}",
                     RouteKeys.MemberController, "Index"), false);
            base.OnActionExecuting(filterContext);
        }
Пример #2
0
        public override void OnActionExecuting(Mvc.ActionExecutingContext filterContext)
        {
            ControllerBase controller = filterContext.Controller as ControllerBase;
            User user = controller.CurrentUser;
            if (user == null || !user.IsAllowedTo(Permission))
                filterContext.Result = new Mvc.HttpUnauthorizedResult();

            base.OnActionExecuting(filterContext);
        }
Пример #3
0
        public override object BindModel(
            Mvc.ControllerContext controllerContext,
            Mvc.ModelBindingContext bindingContext)
        {
            var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

            var modelState = new Mvc.ModelState { Value = valueProviderResult };

            var value = (valueProviderResult != null) ? valueProviderResult.AttemptedValue : null;

            var model = new ArticleSlug(value ?? string.Empty);

            bindingContext.ModelState.Add(bindingContext.ModelName, modelState);

            return model;
        }
Пример #4
0
        public override void OnActionExecuting(Mvc.ActionExecutingContext filterContext)
        {
            // set properties target user and family

            if (!filterContext.RouteData.Values.ContainsKey("id"))
                throw new ArgumentException("Missing Id");

            int id;
            bool hasId = int.TryParse(filterContext.RouteData.Values["id"].ToString(), out id);

            if (!hasId)
                throw new ArgumentException("Missing Id");

            filterContext.Controller.ViewData["id"] = id;

            Initialize(filterContext.Controller as ControllerBase);

            SetTarget(id);

            if (!IsAuthorized())
                filterContext.Result = new Mvc.HttpUnauthorizedResult();

            base.OnActionExecuting(filterContext);
        }