private function LoginValidator::fixOutdatedEmailAddress in Lightweight Directory Access Protocol (LDAP) 8.3
Update an outdated email address.
Return value
bool Email updated.
2 calls to LoginValidator::fixOutdatedEmailAddress()
- LoginValidator::processLogin in ldap_authentication/
src/ Controller/ LoginValidator.php - Perform the actual logging in.
- LoginValidator::processSsoLogin in ldap_authentication/
src/ Controller/ LoginValidator.php - Processes an SSO login.
File
- ldap_authentication/
src/ Controller/ LoginValidator.php, line 701
Class
- LoginValidator
- Handles the actual testing of credentials and authentication of users.
Namespace
Drupal\ldap_authentication\ControllerCode
private function fixOutdatedEmailAddress() {
if ($this->config
->get('emailTemplateUsageNeverUpdate') && $this->emailTemplateUsed) {
return FALSE;
}
if (!$this->drupalUser) {
return FALSE;
}
if ($this->drupalUser
->getEmail() == $this->ldapUser['mail']) {
return FALSE;
}
if ($this->config
->get('emailUpdate') == LdapAuthenticationConfiguration::$emailUpdateOnLdapChangeEnableNotify || $this->config
->get('emailUpdate') == LdapAuthenticationConfiguration::$emailUpdateOnLdapChangeEnable) {
$this->drupalUser
->set('mail', $this->ldapUser['mail']);
if (!$this->drupalUser
->save()) {
$this->logger
->error('Failed to make changes to user %username updated %changed.', [
'%username' => $this->drupalUser
->getAccountName(),
'%changed' => $this->ldapUser['mail'],
]);
return FALSE;
}
elseif ($this->config
->get('emailUpdate') == LdapAuthenticationConfiguration::$emailUpdateOnLdapChangeEnableNotify) {
drupal_set_message($this
->t('Your e-mail has been updated to match your current account (%mail).', [
'%mail' => $this->ldapUser['mail'],
]), 'status');
return TRUE;
}
}
}