protected override bool AuthorizeCore(HttpContextBase httpContext) { var ret = TRControllerBase.CoreAdmin_IsLoggedIn(httpContext); if (ret) { ret = false; var lastTS = TRControllerBase.CoreAdmin_GetLastTimeStamp(httpContext); if (lastTS.HasValue) { var diff = DateTime.Now - lastTS.Value; var to = GetExpireTimeout(); ret = diff < to; } } if (ret) { TRControllerBase.CoreAdmin_SetLastTimeStamp(httpContext); } return(ret); }
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { var isLoggedIn = TRControllerBase.CoreAdmin_IsLoggedIn(filterContext.HttpContext); if (!isLoggedIn) // Unauthorized due to non login { filterContext.Result = new RedirectResult(LoginRedirect); } else // Unauthorized due expiration (assume) { filterContext.Result = new RedirectResult(LogoutinRedirect); } }