Orchard Module only works for logged in users

Topics: Customizing Orchard
Sep 3, 2014 at 3:17 AM
I have a custom module that has a controller and router that display a white page with the word "speedbump" when you go to the url defined in the router but for some reason you can only go to this url when you are logged in. I need to have it accessible by any person visiting the site. Is this possible? Also I have tried adding the [Authorized] and [AllowAnonymous] attributes in my controller but no dice. When I try to visit the url while not logged in it gives the Orchard Access Declined page saying you need to log in.

Controller:
public class AdminController : Controller
{
[HttpPost]
public bool isValidURL(string requestedURL)
{
    //Create a list of strings to contain all the "valid" URLs
    var whiteList = new List<string>();
    //Add URLs to the list
    whiteList.Add("www.google.com");

    foreach (string validURL in whiteList)
    {
        if (requestedURL == validURL)
        {
            //Response.Redirect(requestedURL);
            return true;
        }
    }
    return false;
}
}

Router:
public class Routes : IRouteProvider
{
public void GetRoutes(ICollection<RouteDescriptor> routes)
{
    foreach (var routeDescriptor in GetRoutes())
        routes.Add(routeDescriptor);
}

public IEnumerable<RouteDescriptor> GetRoutes()
{
    return new[] {
        new RouteDescriptor {
            Priority = 15,
            Route = new Route(
                "speedbump",
                new RouteValueDictionary {
                    {"area", "Speedbump"},
                    {"controller", "Admin"},
                    {"action", "isValidURL"}
                },
                new RouteValueDictionary(),
                new RouteValueDictionary {
                    {"area", "Speedbump"}
                },
                new MvcRouteHandler())
        }
    };
}
}
Developer
Sep 3, 2014 at 10:19 AM

If you want it in the admin, you need to enable the Unauthenticated role access to the admin screens. Look in users -> roles -> permissions

Marked as answer by emeraldarcher on 9/3/2014 at 8:25 AM