0

I try to call a SOAP web service before an users authentication. I've try this

function beneficiaire_user_login(&$edit, $account){
    die('hello from login override'); }

Unfortunately, if my SOAP request is bad I cannot prevent the authentication.

What I want to do is: click the login > check via a WS is the user exists > if yes create the user on Drupal, else show an error message. Can I perform this action before the session opening ?

With a form_alter hook, it doesn't works, I do not see the "form alter" text

function beneficiaire_form_alter(&$form, $form_state, $form_id){
    exit('form alter');
}

Thanks

2
  • YOU HAVE TO VALIDATE THE LOGIN FORM AS CUSTOM VALIDATION
    – Rupesh
    Nov 5, 2014 at 14:41
  • Clear the cache
    – Rupesh
    Nov 5, 2014 at 14:56

1 Answer 1

0

I'm working on something similar. I think you can do this using a validation rule.

/**
 * Implements hook_form_alter().
 * We replace the local login validation handler with our own.
 */
 function beneficiaire_form_alter(&$form, &$form_state, $form_id) {
    // In this simple example we authenticate on username to see whether starts with dave
    if ($form_id == 'user_login' || $form_id == 'user_login_block') {
        $form['#validate'][] = 'beneficiaire_user_form_validate';
    }
 }

/**
 * Perform validation rules and set error states
 */
function beneficiaire_user_form_validate($form, &$form_state) {
    if (!beneficiaire_authenticate($form_state)) {
        form_set_error('name', t('You are not on our super-secret list.'));
    }
}

/**
 * Custom user authentication function
 */
 function beneficiaire_authenticate(&$form_state) {
     // Check the webservice here and return false if user not found.
 }
1
  • Oops! Didn't realize I was responding to an old question.
    – TMorgan
    Mar 27, 2015 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.