public function getOrCreateUserFromEmailString($email_string) { $email = $this->getEmailAdressFromSenderString($email_string); if (!($user = User::findUser($email))) { $name = $email; if (($q_pos = strpos($email_string, "<")) !== false) { $name = trim(substr($email_string, 0, $q_pos - 1)); } $user = new User(); try { $user->setBuddyname($name); $user->setEmail($email); $user->setUsername($email); $user->setValidated(); $user->setActivated(); $user->setEnabled(); $user->save(); } catch (\Exception $e) { return null; } } return $user; }
public static function getByEmail($email) { $user = self::getB2DBTable()->getByEmail($email); if (!$user instanceof User && !framework\Settings::isUsingExternalAuthenticationBackend()) { $user = new User(); $user->setPassword(self::createPassword()); $user->setUsername($email); $user->setEmail($email); $user->setActivated(); $user->setEnabled(); $user->setValidated(); $user->save(); } return $user; }