예제 #1
0
        public static void StubLoggedInStatus(Controller controller, NKanbanPrincipal user, bool loggedin = true)
        {
            //stub out HttpContext.Request.IsAuthenticated and HttpContext.Request.User
            var stubContext = A.Fake<HttpContextBase>();
            var stubRequest = A.Fake<HttpRequestBase>();

            A.CallTo(() => stubContext.Request).Returns(stubRequest);
            A.CallTo(() => stubRequest.IsAuthenticated).Returns(loggedin);
            A.CallTo(() => stubContext.User).Returns(user);

            controller.ControllerContext = new ControllerContext(stubContext, new RouteData(), controller);
        }
예제 #2
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            //TODO - Add code to ignore requests for assets like images, js, css, etc
            if (HttpContext.Current == null || HttpContext.Current.User == null)
            {
                return;
            }

            var customPrincipal = new NKanbanPrincipal(new NKanbanIdentity(new FormsIdentityWrapper(HttpContext.Current.User.Identity)));
            HttpContext.Current.User = customPrincipal;
            Thread.CurrentPrincipal = customPrincipal;
        }