using System.Web.Mvc;

namespace Qusion.WebApp.Areas.cms.Filters
{
    public class QusionAuthorize : AuthorizeAttribute
    {
        public string LoginPage { get; set; }

        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (!string.IsNullOrWhiteSpace(LoginPage) && !filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                filterContext.HttpContext.Response.Redirect(LoginPage);
            }
            base.OnAuthorization(filterContext);
        }
    }
}