Force Login - No Anonymous Shopping

Post feature requests to this forum and a pre-configured poll will automatically be created for you.
Post Reply
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Thu Feb 17, 2011 9:14 pm

Force Login - No Anonymous Shopping

Post by aferrara » Sun Feb 20, 2011 10:16 am

As a new AC implementer my first site brought a couple of requirements that do not appear to be "in the box". In my site, the users cannot shop without logging in first. I couldn't find any posts describing exactly how this was accomplished by the community so I implemented a simple technique, although I had to insert a function in each page I needed to protect. I did this by inserting the following logic in pre_init on each page:

Code: Select all

protected void Page_PreInit(object sender, EventArgs e)
        if (Token.Instance.User == null || Token.Instance.User.IsAnonymous)
This seems to work OK and using source control I can manage this simple difference when I upgrade later without a problem, but, since I am not an AC expert I'm wondering if there is something I overlooked or even a quicker/easier way to do this.


User avatar
Commander (CMDR)
Commander (CMDR)
Posts: 112
Joined: Wed Oct 15, 2008 9:30 pm
Location: Boston, MA

Re: Force Login - No Anonymous Shopping

Post by mikek » Sun Feb 20, 2011 3:33 pm

You can enforce account sign in for all site visitors by adding "allow" authorization rule for authenticated users only. Just add the the code below before the </system.web> in your site
web.config file.

<deny users="?" />
<allow users="*" />

This apples to any based site and is not specific to AbleCommerce.
Mike Kolev

Lieutenant (LT)
Lieutenant (LT)
Posts: 55
Joined: Wed Oct 12, 2011 11:15 am

Re: Force Login - No Anonymous Shopping

Post by Tea-Dev » Tue Apr 16, 2013 4:48 pm

The changes to web.config do work, but for some reason, the formatting is all messed up as it odes not inherit any css or layout. How can we invoke the same with the css or layout formatting?

Post Reply