From 6743cf794d285098041c958ba9eda59014493f4f Mon Sep 17 00:00:00 2001 From: Liviu Calin Date: Wed, 13 Nov 2024 16:09:28 +0100 Subject: [PATCH] fix fake email generation use real hostname --- UsuarioLdapComponent.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UsuarioLdapComponent.php b/UsuarioLdapComponent.php index 70d0b7c..fca8667 100644 --- a/UsuarioLdapComponent.php +++ b/UsuarioLdapComponent.php @@ -399,7 +399,12 @@ public function events() { // Gets the email from the ldap user $user->email = $ldap_user->getEmail(); if (empty($user->email)) { - $user->email = uniqid() . "@" . Yii::$app->request->hostName; + $hostName = Yii::$app->request->hostName; + if (strpos($hostName, '.') === false) { + // usefull in case we are in localhost for passing email validator when 'checkDNS' => true + $hostName = $hostName.'.com'; + } + $user->email = uniqid() . "@" . $hostName; } $user->confirmed_at = time(); $user->password_hash = 'x';