Loading cas.module +24 −21 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ $cas_user_manager = \Drupal::service('cas.user_manager'); $account = $form_state->getFormObject()->getEntity(); if (!$account->isNew()) { $cas_username = $cas_user_manager->getCasUsernameForAccount($account->id()); // If a CAS username was found for this user, then populate the CAS username Loading @@ -71,8 +72,9 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ // Users are normally required to entier their current password when // changing their password or email address. Since we are disabling // access to change their password, and since a CAS user would not know // their local Drupal password anyway, we remove this field as well. // access to change their password, and since a CAS user would not // know their local Drupal password anyway, we remove this field as // well. if (isset($form['account']['current_pass'])) { $form['account']['current_pass']['#access'] = FALSE; } Loading @@ -86,6 +88,7 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ } } } } /** * Implements hook_form_FORM_ID_alter(). Loading Loading @@ -204,7 +207,7 @@ function _cas_user_form_submit(array $form, FormStateInterface $form_state) { if ($form_state->getValue('cas_username') && $form_state->getValue('cas_enabled')) { $cas_user_manager->setCasUsernameForAccount($account, $form_state->getValue('cas_username')); } elseif ($cas_user_manager->getCasUsernameForAccount($account->id())) { elseif ($account->id() && $cas_user_manager->getCasUsernameForAccount($account->id())) { $cas_user_manager->removeCasUsernameForAccount($account); } } Loading Loading
cas.module +24 −21 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ $cas_user_manager = \Drupal::service('cas.user_manager'); $account = $form_state->getFormObject()->getEntity(); if (!$account->isNew()) { $cas_username = $cas_user_manager->getCasUsernameForAccount($account->id()); // If a CAS username was found for this user, then populate the CAS username Loading @@ -71,8 +72,9 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ // Users are normally required to entier their current password when // changing their password or email address. Since we are disabling // access to change their password, and since a CAS user would not know // their local Drupal password anyway, we remove this field as well. // access to change their password, and since a CAS user would not // know their local Drupal password anyway, we remove this field as // well. if (isset($form['account']['current_pass'])) { $form['account']['current_pass']['#access'] = FALSE; } Loading @@ -86,6 +88,7 @@ function cas_form_user_form_alter(&$form, FormStateInterface $form_state, $form_ } } } } /** * Implements hook_form_FORM_ID_alter(). Loading Loading @@ -204,7 +207,7 @@ function _cas_user_form_submit(array $form, FormStateInterface $form_state) { if ($form_state->getValue('cas_username') && $form_state->getValue('cas_enabled')) { $cas_user_manager->setCasUsernameForAccount($account, $form_state->getValue('cas_username')); } elseif ($cas_user_manager->getCasUsernameForAccount($account->id())) { elseif ($account->id() && $cas_user_manager->getCasUsernameForAccount($account->id())) { $cas_user_manager->removeCasUsernameForAccount($account); } } Loading