예제 #1
0
            /// <summary>
            /// Function     : OnAuthorization
            /// Objective    : This function to Overide default OnAuthorization function
            /// </summary>
            /// <returns></returns>
            public override void OnAuthorization(AuthorizationContext filterContext)
            {
                var sess     = new HttpContextSessionWrapper();
                var uu       = filterContext.HttpContext != null && filterContext.HttpContext.Request != null && filterContext.HttpContext.Request["username"] != null;
                var userName = uu ? Convert.ToString(filterContext.HttpContext.Request["username"]) : string.Empty;

                if (sess.SessionUser == null || string.IsNullOrEmpty(sess.SessionUser.ID))
                {
                    if (filterContext.HttpContext.Request.Url != null)
                    {
                        var values = new RouteValueDictionary(new
                        {
                            action     = "login",
                            controller = "account",
                            ReturnUrl  = filterContext.HttpContext.Request.Url.PathAndQuery
                        });
                        filterContext.Result = new RedirectToRouteResult(values);
                    }
                    else
                    {
                        filterContext.Result =
                            new RedirectResult(
                                "/account/login", false);
                    }
                }
                else
                {
                    userName = sess.SessionUser.user_email;
                    //_mb
                }
            }
예제 #2
0
            /// <summary>
            /// Function     : OnAuthorization
            /// Objective    : This function to Overide default OnAuthorization function
            /// </summary>
            /// <returns></returns>
            public override void OnAuthorization(AuthorizationContext filterContext)
            {
                var objSessionWrapper = new HttpContextSessionWrapper();

                if ((objSessionWrapper != null && objSessionWrapper.SessionUser == null) || string.IsNullOrEmpty(objSessionWrapper.SessionUser.ID))
                {
                    if (filterContext.HttpContext.Request.Url != null)
                    {
                        var values = new RouteValueDictionary(new
                        {
                            action     = "authFailed",
                            controller = "home",
                            ReturnUrl  = filterContext.HttpContext.Request.Url.PathAndQuery
                        });
                        filterContext.Result = new RedirectToRouteResult(values);
                    }
                    else
                    {
                        filterContext.Result =
                            new RedirectResult(
                                "/home/authFailed", false);
                    }
                }
            }