Force user login

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
DavidR63
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Wed Aug 20, 2008 4:06 pm

Force user login

Post by DavidR63 » Wed Aug 20, 2008 4:08 pm

Is there a way to force user logins? Our use of AbleCommerce would be for an internal ordering system, we only want certain people to be able to login to order from the site. No one would be able to see the products at all until they logged in.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Force user login

Post by AbleMods » Thu Aug 21, 2008 10:52 pm

Interesting concept. I"m not sure how feasible it would be for such a configuration. AC7 is designed for anonymous access first.

The simplest way would be to turn off anonymous access to the web site itself in IIS. IIS will force a credentials prompt and authenticate against the local server OS security database before site access would be allowed.

The amount of overall effort depends on what anonymous people should be able to see.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

DavidR63
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Wed Aug 20, 2008 4:06 pm

Re: Force user login

Post by DavidR63 » Fri Aug 22, 2008 10:06 am

I figured out a way to do what I wanted. This may not work if you use the 'Site Disclaimer Message' since it will redirect it to the login page or it will try to modify the response headers after they have already been written by the disclaimer message page. I may work on a fix for that but I don't use that so I'm not concerned with it at this point. In order for this to work across the board you have to edit the 'Scriptlet.master' file in the 'Layouts' directory. This may cause issues when upgrading, I believe this file may potentially be overwritten by an upgrade. If anyone has any suggestions on a way to keep this modification but avoid upgrade conflict issues please let me know.

Code: Select all

    <script runat="server">
         protected void Page_Load(object sender, EventArgs e)
         {                 
             // Redirect visitor to login page if they have not logged in yet. Anonymouse access
             // is not allowed at this site.
             if (Request.Url.LocalPath.ToLower() != "/login.aspx" &&
                 Token.Instance.User.IsAnonymous)
             {
                 Response.Redirect("~/Login.aspx");
             }
         } 
    </script>
I just put this after all the <%@ Register %> tags. I welcome any and all feedback, good or bad.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Force user login

Post by jmestep » Tue Nov 25, 2008 8:45 am

I had to make one change to this because a customer wasn't able to access the reset password page when they had forgotten the password and requested it in an email.

Code: Select all


<script runat="server">
         protected void Page_Load(object sender, EventArgs e)
         {                 
             // Redirect visitor to login page if they have not logged in yet. Anonymous access
             // is not allowed at this site.
             if (Request.Url.LocalPath.ToLower() != "/login.aspx" && Request.Url.LocalPath.ToLower() != "/passwordhelp.aspx" &&
                 Token.Instance.User.IsAnonymous)
             {
                 Response.Redirect("~/Login.aspx");
             }
         } 
    </script>
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply