function simplesamlphp_auth_form_alter in simpleSAMLphp Authentication 7.2
Same name and namespace in other branches
- 6.3 simplesamlphp_auth.module \simplesamlphp_auth_form_alter()
- 6.2 simplesamlphp_auth.module \simplesamlphp_auth_form_alter()
- 7.3 simplesamlphp_auth.module \simplesamlphp_auth_form_alter()
- 7 simplesamlphp_auth.module \simplesamlphp_auth_form_alter()
Implements hook_form_alter().
File
- ./
simplesamlphp_auth.module, line 466 - simpleSAMLphp authentication module for Drupal.
Code
function simplesamlphp_auth_form_alter(&$form, $form_state, $form_id) {
if (!_simplesamlphp_auth_isEnabled()) {
// Exit without executing.
return;
}
if ($form_id == 'user_login_block') {
$link = l(t('Federated Log In'), 'saml_login');
$links = $form['links']['#markup'];
$links = str_replace('</ul>', '<li class="saml">' . $link . '</li></ul>', $links);
$form['links']['#markup'] = $links;
}
if ($form_id == 'user_account_form') {
$link = l(t('Federated Log In'), 'saml_login');
$links = $form['links']['#markup'];
$links = str_replace('</ul>', '<li class="saml">' . $link . '</li></ul>', $links);
$form['links']['#markup'] = $links;
}
// If the user has a simplesamlphp_auth authmap record, then don't require
// them to know their Drupal password. This will allow them to change their
// e-mail address, and set a Drupal password if they want to and are allowed.
if (isset($form['#user']->init) && $form['#user']->init && (_simplesaml_auth_user_has_authmap($form['#user']->init) && $form_id == 'user_profile_form')) {
unset($form['account']['current_pass']);
unset($form['account']['current_pass_required_values']);
$form['#validate'] = array_diff($form['#validate'], array(
'user_validate_current_pass',
));
// If the user is a simplesamlphp_auth user and is NOT allowed to set their
// Drupal password, remove the fields from the form.
if (!variable_get('simplesamlphp_auth_allowsetdrupalpwd')) {
unset($form['account']['pass']);
}
}
}