Skip to content

Commit

Permalink
move text to const
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed May 29, 2024
1 parent 4963f89 commit 61ab495
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/Authorization/Service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
final readonly class MailService implements MailServiceInterface
{
private const RESET_MAIL_TEXT = "Login to pimcore and change your password using the following link.
This temporary login link will expire in 24 hours: \r\n\r\n %s";
private string $domain;

public function __construct(
Expand Down Expand Up @@ -76,16 +78,10 @@ public function sendResetPasswordMail(UserInterface $user, string $token): void
try {
$mail = $this->toolResolver->getMail([$user->getEmail()], 'Pimcore lost password service');
$mail->setIgnoreDebugMode(true);
$mail->text(
sprintf(
"Login to pimcore and change your password using the following link.
This temporary login link will expire in 24 hours: \r\n\r\n %s",
$loginUrl
)
);
$mail->text(sprintf(self::RESET_MAIL_TEXT, $loginUrl));
$mail->send();
} catch (Exception $e) {
throw new SendMailException();
} catch (Exception $exception) {
throw new SendMailException($exception->getMessage());
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Exception/SendMailException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

namespace Pimcore\Bundle\StudioBackendBundle\Exception;

use Throwable;

/**
* @internal
*/
final class SendMailException extends AbstractApiException
{
public function __construct()
public function __construct(string $originalMessage)
{
parent::__construct(
500,
'Failed to send reset password mail'
sprintf('Failed to send reset password mail: %s', $originalMessage),
);
}
}

0 comments on commit 61ab495

Please sign in to comment.