Jump to content
ArtcoInc

Faster login with bootstrap modal

Recommended Posts

I hired a freelancer to AJAX/JQuery functionality to this module.  It's done and works really well.  Although I couldn't have created the code I could follow it along and as nearly as I can tell everything looks really well written and commented.  Would you guys like me to upload it to this thread?  Just wanted to check as I don't want to offend anyone.  Thanks.

Share this post


Link to post
Share on other sites

@@ndiggity

 

I'd like to see what they came up with. There's no problem with sharing in this community :)


Let's make things easier for new osCommerce users http://forums.oscommerce.com/topic/402638-discussion-about-hard-coded-database-tables/?p=1718900  Getting there with osCommerce 2.4! :thumbsup:

Share this post


Link to post
Share on other sites

I just found that there's a problem with this code if you want to redirect after login... I'm not using it in that way so, I didn't see it at first.  Any thoughts on the best way to utilize the AJAX functionality if the php_self and redirect are the same but not if they are different?  Just removing all the if (ajaxLogin != 'True') looks like it would do it.

Edited by ndiggity

Share this post


Link to post
Share on other sites

I've had more time to test this code and found that removing above mentioned code seems to give the desired functionality.  So, if you're on a random page and just login that random page will not be reloaded (this is important to me).  However, if you click a link that goes to a different page that requires login then the AJAX login is performed and the nonAJAX code kicks in to go to the redirect page.  The attached code also fixed one typo that is inconsequential. 

 

The only caveat I saw so far contrary to the above described functionality is on shopping_cart.php.  If you're not logged in and have something in your shopping cart and then you login it does a page reload.  This isn't important to me but I thought I'd mention it.  I'd love to know if any of the osC gurus here have any thoughts on improvements. It may be hair brained but perhaps the code added to cm_login_form.php for the AJAX login should be moved to a new file to retain the drop on top module beauty even though the code would be slightly redundant.  What are your guys thoughts?

login_modal_module_v2_1_withAJAX_RedirectFix.zip

Edited by ndiggity

Share this post


Link to post
Share on other sites

I am amazed at how far this idea has evolved in the last 2 years. Thank you everyone for your contributions and efforts!

 

@@ndiggity

 

I have to ask the question that was raised before ... how does work if called from a non-SSL page? Assuming that there is an SSL certificate for the site, can it/will it enable the login to be made encrypted? I know *nothing* about AJAX.

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@ArtcoInc

 

I'm working on a development subdomain to set up our new store before moving it over to our live site.  The development store has an SSL cert and the configure.php file is set up for https for both SSL and nonSSL pages.  I have not yet done anything with the .htaccess file to redirect http to https.  If you like, I can change the configure.php file so that http pages are http and test it for you.  Please just let me know what page(s) to test, what browser, what to look for, etc.  To be honest, I know enough about this stuff to hack around a little and am generally proficient with PHP but I'm certainty not a pro like a lot of the guys on here.  I know nothing about AJAX either.

Share this post


Link to post
Share on other sites

@@ndiggity

 

When I first came up the the BS Modal login, I knew nothing about SSL. Someone pointed out that since the Modal was being called from a non-SSL page, the Modal itself was non-SSL. Thus, the login was not encrypted.

 

My site currently is not full time SSL, using the default SSL / non-SSL arrangement that osC uses. I've not worried too much about this in the past. But new browsers are now alerting (alarming?!) users that such logins are not encrypted. I plan to go full SSL sometime soon. But, in the mean time ...

 

So, if you could please test yours with configure.php set to the 'default' SSL settings, and see if your browser flags the AJAX login as secure or not. I think the latest versions of either Firefox and/or Chrome should warn you if it isn't.

 

Thanks!

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@ArtcoInc

 

Firefox tagged the password field as "not secure" when using the 'default' SSL settings. And here's a new development...  http to http and https to https work fine but when using the 'default' settings of http to https the AJAX fails.  I'm going to see if I can figure out what's going on. But I don't know much about AJAX... Are there any AJAX gurus out there with any insight into http to https requests?

Share this post


Link to post
Share on other sites

@@ndiggity

 

Same as the problem I had with the Modal. :wacko:  Thanks for testing.

 

By the way, I didn't mean to throw a wrench into your works. :-

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@ArtcoInc

 

LOL... No worries.  If this is the worst thing to happen to me today then today is the best day all month :-)  I think http to https has to do with AJAX seeing the two pages as different domains.  Apparently, there are ways of performing cross domain AJAX requests.  Take a look here... https://www.matraex.com/php-solution-to-http-to-https-ajax-call-no-access-control-allow-origin-header-is-present-on-the-requested-resource/

Share this post


Link to post
Share on other sites

@@ArtcoInc

 

Take this with a grain of salt but I've done a little digging and pretty much everyone says there is no secure way of embedding https stuff within a http page or securely capturing data in a http page to be transmitted to a https page,  Apparently, header("Access-Control-Allow-Origin: http://$_SERVER[HTTP_HOST]"); and jsonp *can* be used for cross domain AJAX but its not secure.  I think the answer here is if you're concerned enough about security to have some https on your site then just go to a full https site. IDK :D

Share this post


Link to post
Share on other sites

@@ndiggity

 

The security issue has been discussed previously and best solution was to only use the login modal on a fully SSL'd site.

 

I like what you're trying to do here but you need to remember that there are a number of areas on the page that need to be updated after user login. The navbar which you have already addressed, but there is also the footer, customer's order history box needs to appear if enabled and if the shopping cart box is being used then that also needs to be updated. There could be more.

 

Having the pages load using ajax would be a cool thing, but the only time this is going to happen using your code is when no redirect is required. In my opinion, then what is the point of using ajax at all since there are still a number of areas of the page that need to be updated (as mentioned), even when there is no redirect.

 

The point of the login modal was to eliminate an extra page load (to the login page) when logging in, which has been achieved. Trying to eliminate another page load seems like a good idea but that won't work anyway if a redirect is required.

 

cheers

Edited by auzStar

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Share this post


Link to post
Share on other sites

@@auzStar

 

I hadn't appreciated the general uselessness of AJAX for a page that requires redirect but what you said makes perfect sense.  Thank you for saying it (and for saying it nicely :) ).  I have a unique situation where on a particular page in my store a customer can get lose data if they are not logged in before opening the page and requiring login to access the page doesn't make sense.  Login without reload is critically important to me for this page.  The AJAX addition to your Login Modal solves this problem for me.

 

Taking into consideration what you said, I think I'm going to tweak the code to make it more appropriate for general use (no need for AJAX login on most pages) while still enabling AJAX login for certain pages and fix at least the footer update.  It would probably make sense to move the code added to cm_login_form.php to a new page in the catalog directory so additional code could be more easily added to update other areas as required.  Now that I think about it, there probably aren't a lot of folks that *actually* benefit from AJAX login and for them it might cause more problems than solutions :wacko:  I'll post the code here just in case anyone really needs it... But as you alluded they might as well use your version and avoid unnecessary problems.

Edited by ndiggity

Share this post


Link to post
Share on other sites

I applied the following updates to the code...

 

1. I moved the AJAX login stuff to a new file.  This eliminates the need for code editing.

2. I updated the AJAX login to update the footer.  I also commented in which sections additional update code should be added.

3. I added code so that you can select on which pages the regular redirect/reload is used and on which pages AJAX login is used.

 

As discussed above, if you don't truly have the need for page update without reload then this code is unnecessary (and might just cause confusion) and you should just use the code in post 72

login_modal_module_v2_1_withAJAXandPageSelection.zip

Edited by ndiggity

Share this post


Link to post
Share on other sites

I installed this on a on my local test install and can't get the modal to popup. Am I missing something? The instructions said to just drop the files in and install in admin.

Share this post


Link to post
Share on other sites
On 3/12/2019 at 6:46 AM, Tsimi said:

@LeeFoster

Which file set did you install? Link?

Could my issue be that my site isn't fully SSL secured as it is a local version?

Share this post


Link to post
Share on other sites

I have never used that file set before so can't say. But I would guess SSL has nothing to do with the modal not popping up.

What's the store version? Frozen or Edge?

Share this post


Link to post
Share on other sites
2 hours ago, Tsimi said:

I have never used that file set before so can't say. But I would guess SSL has nothing to do with the modal not popping up.

What's the store version? Frozen or Edge?

BS4 edge, which file set would you suggest?

Share this post


Link to post
Share on other sites

To be honest, don't know. I haven't looked at it for a very long time.

I just asked about the file set and store version so that i can try it out in the same setup as you did.

Share this post


Link to post
Share on other sites
34 minutes ago, Tsimi said:

To be honest, don't know. I haven't looked at it for a very long time.

I just asked about the file set and store version so that i can try it out in the same setup as you did.

Fair enough, don't worry about it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×