From 3c32144260ad8edff8aefad012218e59841d2d63 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Tue, 21 Sep 2010 21:13:57 +0000 Subject: [PATCH] Enable email address changes without password confirmation when CAS is enabled. Also make it impossible to edit the user profile form to change a password even thought the fields are normally hidden. git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@182 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/unl/unl_cas.module | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sites/all/modules/unl/unl_cas.module b/sites/all/modules/unl/unl_cas.module index da55f624..fcc186ef 100644 --- a/sites/all/modules/unl/unl_cas.module +++ b/sites/all/modules/unl/unl_cas.module @@ -102,10 +102,27 @@ function unl_cas_form_alter(&$form, $form_state, $form_id) $form['picture']['#description'] = 'To change your picture, visit <a href="http://planetred.unl.edu/pg/profile/unl_' . $GLOBALS['user']->name .'">Planet Red</a>.'; $form['picture']['picture_delete']['#type'] = 'hidden'; $form['picture']['picture_upload']['#type'] = 'hidden'; + + // Disable checking the current password when changing email. + if ($validate_password_index = array_search('user_validate_current_pass', $form['#validate']) !== FALSE) { + unset($form['#validate'][$validate_password_index]); + } + + $form['#validate'][] = 'unl_cas_user_profile_form_validate'; } } +/** + * Make sure there's no funny business with somebody trying to change a password when we're using CAS. + */ +function unl_cas_user_profile_form_validate(&$form, &$form_state) +{ + if ($form_state['values']['pass']) { + form_set_error('current_pass', t('Password changes are not allowed when CAS is enabled!')); + } +} + function unl_cas_user_logout($account) { session_destroy(); -- GitLab