Currently, the module will add a password textfield and "Login now" button to the Account Information checkout pane when an existing e-mail address is used. However, if that button is clicked, login won't actually occur. We need to attempt login and accommodate the following items:

  1. Incorrect passwords
  2. Redirecting back to checkout
  3. Conflicts with other login code
  4. Anonymous cart conversion

Comments

BenK’s picture

Subscribing

Ceb’s picture

Subscribing. May try and figure out some code... but I can't guarantee I'll be helpful.

latulipeblanche’s picture

What is the status of this Module ?

ajtoelle’s picture

StatusFileSize
new4.5 KB

I managed to hack this module so it has the basic functionality [for my current project's needs]... Not sure if this is the right way to go about it, but thought i'd share a patch so somebody more knowledgeable can take a look.

I'm using this in tangent with the email_registration module..... don't... know... if that's.. important.. ; |

svendecabooter’s picture

Status: Active » Needs review
StatusFileSize
new2.28 KB

Here is a first attempt at actually implementing this:

* Attempts to login user if email address + password are provided
* Does most of the validation that Drupal core also performs (except flood login checking).
* Assigns the order to the user once login is successful

I might also implement extra functionality to optionally for the user to be logged in (although that might not really be best practice from a usability point of view), and try to find a way to make this work without Javascript.

m_wiking’s picture

I tried the patch in #5 and it works when the user write a proper password but when I put a invalid password I get this message back:

Notice: Undefined index: uid in commerce_checkout_login_checkout_form_submit() (line 94 of /Users/mattias/NetBeansProjects/mysite/sites/all/modules/commerce_checkout_login/commerce_checkout_login.module).

svendecabooter’s picture

Thanks for testing the patch.
Does it break the desired functionality or not?

If a user can't be authenticated, the form submit shouldn't be called, so it should never arrive at line 94 :(
Did this happen when you clicked the "Login now" button, or the "Continue to next step" button?

m_wiking’s picture

I pressed the login button to get this error.

EndEd’s picture

Subscribe

ilavir’s picture

subscribe

when I've applyed the patch #5, I have an error "Notice: Undefined index: storage in commerce_checkout_login_checkout_form_submit() (line 95 of /sites/all/modules/commerce_checkout_login/commerce_checkout_login.module)." when a wrong password entered.

EndEd’s picture

Hi looking at the code I think the problem is the use of #limit_validation_errors property. As I see here this makes the submition funcition run even the user input is not validated (even messages form form_set_error are not shown).

$form['account']['login']['login_now'] = array(
  '#type' => 'submit',
  '#value' => t('Login now'),
  '#limit_validation_errors' => array(), // HERE
  '#validate' => array('commerce_checkout_login_checkout_form_validate'),
  '#submit' => array('commerce_checkout_login_checkout_form_submit'),
);

EDIT: I've change that line to

'#limit_validation_errors' => array(array('account', 'login', 'password')),

and now is working for me. Going to test a little more.

tscadfx’s picture

StatusFileSize
new7.73 KB

Hey Ryan,

Is there anyway we can get a commit of this. I've done some extensive testing on it and it appears to work without problems.

Thanks

rszrama’s picture

Of the patch in #5?

tscadfx’s picture

I attached a zip file of everything in #12. It's including the patch in 5 and a couple small changes to fix the error when the password is wrong.

I've tried it out, as is in the zip, and can't get it to error under many circumstances.

rszrama’s picture

Ok, I can't really review a zip like that. Any way you can turn that into a patch or set of patches?

See http://drupal.org/patch/create

tscadfx’s picture

StatusFileSize
new2.38 KB

Here's a working patch. Sorry I was being lazy.

tscadfx’s picture

StatusFileSize
new2.39 KB

Line 50 & 78 code cleanup.

dpolant’s picture

Patch #17 works.

deepbluesolutions’s picture

patch in #17 works for me too

rszrama’s picture

Status: Needs review » Fixed

Alrighty, finally got around to a review of this. Thanks to those who have worked on it so far, it provided a very easy base for me to work from. I had to make only the two changes explained below:

  • #limit_validation_errors only needs to indicate a child array of the $form_state['values']['array'] when it wants to limit validation errors to a particular part of the form. In our case, we want to validate anything in the account information checkout page, i.e. $form_state['values']['account']. So I changed the #limit_validation_errors array to only specify 'account', as everything else will be nested beneath it in the array.
  • As is, the patch was storing the valid uid in $form_state['storage'] and then just unsetting the whole storage array on submission. This is problematic because other modules may be using the storage array; it's not uncommon, and who knows what people might do with it here. I just tweaked it to use a custom variable in the form state instead, $form_state['commerce_checkout_login_uid'].

Committed! Thanks for the team effort. I'm not experiencing any problems in my tests, and I left the @todo in there about flood control.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.