I simply have a question and would like to know if I am doing something wrong.

Right now I have a bug where if I log in to Drupal for the first time with a vBulletin user, it will create a user in Drupal, but will not log me in to Drupal. I have to then log in one more time in order to get a logged in session to Drupal. Subsequent log ins work fine the first time, but this is because I have a user in Drupal at this point.

I noticed in drupalvb_form_alter that its checking for the user_login_final_validate validator and replacing it with drupalvb_login_validate, why are you not just putting drupalvb_login_validate first in the array of validation callbacks so that it will get called first, create the user in Drupal and then run the regular Drupal validation callbacks which will then work like they should because at that point a user has been created in Drupal? Is there something I am missing?

I made the following change and I can now log in when I try to log in for the first time:

-        $key = array_search('user_login_final_validate', $form['#validate']);
-        if ($key !== FALSE) {
-          array_splice($form['#validate'], $key, 0, 'drupalvb_login_validate');
-        }
-        else {
-          // Another module altered the validation sequence before us, not sure
-          // how to properly handle this case...
-          $form['#validate'] = array('drupalvb_login_validate') + $form['#validate'];
-        }
+        $form['#validate'] = array('drupalvb_login_validate') + $form['#validate'];

Basically just putting the drupalvb validation callback first in all cases.

Comments

sun’s picture

You might be interested in the patch in #982894: Redirect to originating page when logging in from vBulletin - possibly resolves this issue.