Apologies for what is possibly a real newbie question.
Its my first attempt at working on a drupal module, and I'm new to drupal in general...

I have been asked to do some work on making SSO login possible in Drupal 7.

I have the module working. Users can login without need for a password.

The module allows users to login with just their username.
(I use a type of SSO to do external auth to verify the user in the login_validate.)

However I keep getting the message "Password field is required" displayed despite the fact that the user has been successfully logged in and the black bar appears over on the top of the page with the "Hello username" message etc...

I have tried a few different things, like this below, in the form alter to un-require the password field but can't get it...


function mymodule_form_user_login_alter( &$form, $form_state ){
   $form['user-login-form']['edit-pass']['#required'] = FALSE;
}

I don't want to hide the password field, I want to leave it there so that the drupal admin can login as normal if needed.

Just when a user who should be able to log in via external auth tries to log in, they shouldn't be required to enter a password.

So, can anyone tell me the right way to do this?

I notice that the required field message comes up even when I cut the form validation down to just my validate:

$form['#validate'] = array( 'mymodule_login_validate' );

Thanks
Vida

Comments

DWB Internet’s picture

Instead of:

$form['user-login-form']['edit-pass']['#required'] = FALSE;

try:

$form['pass']['#required'] = FALSE;

Regards, Marcel

vidapura’s picture

It was THAT easy ???

Fantastic!

Thanks very much Marcel!!