Source

main-vinayFork / Source / WebClient / Web.Client / Infrastructure / RegisteredUser.cs

Full commit
using System.Web.Mvc;

namespace DataUp.Web.Client.Infrastructure
{
    public class RegisteredUser : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            bool isUserRegistered = false;

            if (filterContext.HttpContext.Session["IsUserRegistered"] != null)
            {
                bool.TryParse(filterContext.HttpContext.Session["IsUserRegistered"].ToString(), out isUserRegistered);
            }

            if (!isUserRegistered)
            {
                filterContext.Result = new RedirectResult
                    (
                        "~/Authentication/Register?UrlReferrer="
                        + filterContext.RouteData.Values["controller"].ToString()
                        + "/"
                        + filterContext.RouteData.Values["action"].ToString()
                    );
            }
        }
    }
}