settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); $this->forgotHash = $this->getLifeTimeTimestamp() . '|' . $this->generateHash($random, $hashService); $this->resolveFromTypoScript(); } /** * Returns the forgot hash. */ public function getForgotHash(): string { return $this->forgotHash; } /** * Returns email template name configured in TypoScript */ public function getMailTemplateName(): string { return $this->mailTemplateName; } /** * Returns TTL timestamp of the forgot hash */ public function getLifeTimeTimestamp(): int { if ($this->timestamp === null) { $lifetimeInHours = (int)($this->settings['forgotLinkHashValidTime'] ?? 0) ?: 12; $currentTimestamp = $this->context->getPropertyFromAspect('date', 'timestamp'); $this->timestamp = $currentTimestamp + 3600 * $lifetimeInHours; } return $this->timestamp; } /** * Returns reply-to address if configured otherwise null. */ public function getReplyTo(): ?Address { return $this->replyTo; } /** * Returns the sender. Normally the current typo3 installation. */ public function getSender(): Address { return $this->sender; } protected function generateHash(Random $random, HashService $hashService): string { $randomString = $random->generateRandomHexString(16); return $hashService->hmac($randomString, self::class, HashAlgo::SHA3_256); } protected function resolveFromTypoScript(): void { $fromAddress = ($this->settings['email_from'] ?? null) ?: $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; if (empty($fromAddress)) { throw new IncompleteConfigurationException( 'Either "$GLOBALS[\'TYPO3_CONF_VARS\'][\'MAIL\'][\'defaultMailFromAddress\']" or extension key "plugin.tx_felogin_login.settings.email_from" cannot be empty!', 1573825624 ); } $fromName = ($this->settings['email_fromName'] ?? null) ?: $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']; if (empty($fromName)) { throw new IncompleteConfigurationException( 'Either "$GLOBALS[\'TYPO3_CONF_VARS\'][\'MAIL\'][\'defaultMailFromName\']" or extension key "plugin.tx_felogin_login.settings.email_fromName" cannot be empty!', 1573825625 ); } $this->sender = new Address($fromAddress, $fromName); if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailReplyToAddress'])) { if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailReplyToName']) { $this->replyTo = new Address( $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailReplyToAddress'], $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailReplyToName'] ); } else { $this->replyTo = new Address( $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailReplyToAddress'] ); } } $this->mailTemplateName = (string)($this->settings['email']['templateName'] ?? ''); if (empty($this->mailTemplateName)) { throw new IncompleteConfigurationException( 'Key "plugin.tx_felogin_login.settings.email.templateName" cannot be empty! Ensure that TypoScript is properly included.', 1584998393 ); } } }