53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
use function DI\autowire, DI\create, DI\get;
|
|
|
|
use %NAMESPACE%\Entity;
|
|
|
|
use Ulmus\Entity\Field\Datetime,
|
|
Ulmus\User\Lib\Authenticate;
|
|
|
|
use Storage\{ Session, Cookie };
|
|
|
|
use Laminas\Diactoros\Response\{ RedirectResponse, HtmlResponse };
|
|
|
|
use Notes\Security\SecurityHandler;
|
|
|
|
use Picea\Picea;
|
|
|
|
use TheBugs\Email\{ EmailConfiguration, MailerInterface, SwiftMailer };
|
|
|
|
return [
|
|
Entity\User::class => autowire(Entity\User::class),
|
|
|
|
Authenticate::class => create(Authenticate::class)->constructor(get(Session::class), get(Cookie::class), get('authentication.method')),
|
|
|
|
SecurityHandler::class => create(SecurityHandler::class)->constructor(function() {
|
|
return new RedirectResponse(getenv("URL_BASE")."/connexion");
|
|
}),
|
|
|
|
'authentication.error' => function($c, Picea $picea) {
|
|
return function($message) use ($picea) {
|
|
return new HtmlResponse($picea->renderHtml('lean/error/500', [
|
|
'title' => "",
|
|
'subtitle' => "",
|
|
'message' => $message,
|
|
]));
|
|
};
|
|
},
|
|
|
|
EmailConfiguration::class => function($c) {
|
|
$email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP );
|
|
$email->smtpHost = getenv('SMTP_HOST');
|
|
$email->smtpPort = getenv('SMTP_PORT');
|
|
$email->smtpUsername = getenv('SMTP_USERNAME');
|
|
$email->smtpPassword = getenv('SMTP_PASSWORD');
|
|
$email->smtpUseTLS = getenv('SMTP_TLS');
|
|
$email->toAddress = getenv("TO_EMAIL");
|
|
$email->fromAddress = getenv("FROM_EMAIL");
|
|
$email->fromName = getenv("FROM_NAME");
|
|
|
|
return $email;
|
|
},
|
|
];
|