public static function EmailTemplateService::profileNeedsUpdate in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 ldap_authentication/src/Routing/EmailTemplateService.php \Drupal\ldap_authentication\Routing\EmailTemplateService::profileNeedsUpdate()
Whether or not the user's profile is valid or needs to be updated on login.
Currently this only checks if mail is valid or not according to the authentication settings.
@todo This should not be called statically, so that we don't call all these services without DI.
Return value
bool TRUE if the user's profile is valid, otherwise FALSE.
2 calls to EmailTemplateService::profileNeedsUpdate()
- EmailTemplateService::checkForEmailTemplate in ldap_authentication/
src/ Routing/ EmailTemplateService.php - Form submit callback to check for an email template and redirect if needed.
- LdapAuthenticationProfileUpdateForm::buildForm in ldap_authentication/
src/ Form/ LdapAuthenticationProfileUpdateForm.php - Form constructor.
File
- ldap_authentication/
src/ Routing/ EmailTemplateService.php, line 76
Class
- EmailTemplateService
- Email template service.
Namespace
Drupal\ldap_authentication\RoutingCode
public static function profileNeedsUpdate() : bool {
$proxy = \Drupal::currentUser();
$result = FALSE;
// We only want non-anonymous and non-1 users.
// @todo Role exclusion needs to be checked, user 1 special case removed.
if ($proxy
->id() !== 1 && $proxy
->isAuthenticated()) {
$user = User::load($proxy
->id());
$regex = \Drupal::config('ldap_authentication.settings')
->get('emailTemplateUsagePromptRegex');
$regex = sprintf('`%s`i', $regex);
$mail = $user
->get('mail')->value ?: '';
if (preg_match($regex, $mail)) {
$result = TRUE;
}
}
return $result;
}