Maverick.Web.Controllers.IdentityController.Logout C# (CSharp) Method

Logout() private method

private Logout ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
        public ActionResult Logout()
        {
            IdentitySource identitySource = null;

            // If there's an "authenticated-by" claim in the token, we can use that to identify the identity source
            UserIdentity identity = Thread.CurrentPrincipal.AsUserIdentity();

            if (!String.IsNullOrEmpty(identity.IdentifiedBy)) {
                identitySource = GetIdentitySource(identity.IdentifiedBy);
            }

            // Remove the session token
            SessionIdentityManager.ClearSessionPrincipal();

            // If we found an identity source, give it a chance to log out
            if(identitySource != null) {
                identitySource.Logout(ControllerContext);
            }

            return RedirectToAction("View", "Page", new {page = (Page)null});
        }

Usage Example

Esempio n. 1
0
        public void Logout_Redirects_To_Home_Page()
        {
            // Arrange
            var controller = new IdentityController();
            controller.IdentitySources.AddMock(UnusedMockIdentitySource);

            var mockSessionManager = new Mock<ISessionIdentityManager>();
            controller.SessionIdentityManager = mockSessionManager.Object;

            // Act
            ActionResult result = controller.Logout();

            // Assert
            ResultAssert.IsRedirectToRoute(result, new {controller = "Page", action = "View", page = (Page)null});
        }
All Usage Examples Of Maverick.Web.Controllers.IdentityController::Logout