-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
374 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/app/Resources/modules/security/registration/index.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{# | ||
Template used to print content outside of the claroline app. | ||
This is used to print PDFs and Emails. | ||
#} | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="{{ app.request.locale }}" class="claroline-app {{ config.getParameter('theme') }}" data-bs-theme="light"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
{% if title is not empty %} | ||
<title>{{ title }}</title> | ||
{% endif %} | ||
|
||
{# This is required in order to correctly manage relative path (mostly for tinyMce contents) #} | ||
<base href="{{ baseUrl ~ '/' }}" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
||
{# We will need to load a specific stylesheets later #} | ||
<link rel="stylesheet" type="text/css" href="{{ absolute_url(themeAsset('bootstrap.css')) }}" media="all" /> | ||
</head> | ||
|
||
<body> | ||
{{ content | raw }} | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/* | ||
* This file is part of the Claroline Connect package. | ||
* | ||
* (c) Claroline Consortium <consortium@claroline.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Claroline\AuthenticationBundle\Manager; | ||
|
||
use Claroline\AppBundle\Event\StrictDispatcher; | ||
use Claroline\CoreBundle\Entity\User; | ||
use Claroline\CoreBundle\Event\CatalogEvents\SecurityEvents; | ||
use Claroline\CoreBundle\Event\Security\ForgotPasswordEvent; | ||
use Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler; | ||
use Claroline\CoreBundle\Manager\LocaleManager; | ||
use Claroline\CoreBundle\Manager\MailManager as BaseMailManager; | ||
use Claroline\CoreBundle\Manager\Template\TemplateManager; | ||
use Claroline\CoreBundle\Manager\UserManager; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
class MailManager | ||
{ | ||
public function __construct( | ||
private TranslatorInterface $translator, | ||
private UrlGeneratorInterface $router, | ||
private StrictDispatcher $dispatcher, | ||
private PlatformConfigurationHandler $config, | ||
private BaseMailManager $mailManager, | ||
private LocaleManager $localeManager, | ||
private TemplateManager $templateManager, | ||
private UserManager $userManager | ||
) { | ||
} | ||
|
||
public function sendForgotPassword(User $user): bool | ||
{ | ||
$this->dispatcher->dispatch(SecurityEvents::FORGOT_PASSWORD, ForgotPasswordEvent::class, [$user]); | ||
|
||
$locale = $this->localeManager->getLocale($user); | ||
$placeholders = [ | ||
'first_name' => $user->getFirstName(), | ||
'last_name' => $user->getLastName(), | ||
'username' => $user->getUsername(), | ||
]; | ||
|
||
if (!$user->isEnabled()) { | ||
$subject = $this->templateManager->getTemplate('user_disabled', $placeholders, $locale, 'title'); | ||
$body = $this->templateManager->getTemplate('user_disabled', $placeholders, $locale); | ||
|
||
return $this->mailManager->send($subject, $body, [$user], null, [], true); | ||
} | ||
|
||
$this->userManager->initializePassword($user); // should not be done here (only manage email sending here) | ||
|
||
$placeholders['password_reset_link'] = $this->router->generate( | ||
'claro_index', | ||
[], | ||
UrlGeneratorInterface::ABSOLUTE_URL | ||
)."#/newpassword/{$user->getResetPasswordHash()}"; | ||
|
||
$subject = $this->templateManager->getTemplate('forgotten_password', $placeholders, $locale, 'title'); | ||
$body = $this->templateManager->getTemplate('forgotten_password', $placeholders, $locale); | ||
|
||
return $this->mailManager->send($subject, $body, [$user], null, [], true); | ||
} | ||
|
||
public function sendInitPassword(User $user): bool | ||
{ | ||
$this->userManager->initializePassword($user); // should not be done here (only manage email sending here) | ||
|
||
$link = $this->router->generate( | ||
'claro_index', | ||
[], | ||
UrlGeneratorInterface::ABSOLUTE_URL | ||
)."#/newpassword/{$user->getResetPasswordHash()}"; | ||
$locale = $this->localeManager->getLocale($user); | ||
$placeholders = [ | ||
'first_name' => $user->getFirstName(), | ||
'last_name' => $user->getLastName(), | ||
'username' => $user->getUsername(), | ||
'password_initialization_link' => $link, | ||
]; | ||
$subject = $this->templateManager->getTemplate('password_initialization', $placeholders, $locale, 'title'); | ||
$body = $this->templateManager->getTemplate('password_initialization', $placeholders, $locale); | ||
|
||
return $this->mailManager->send($subject, $body, [$user], null, [], true); | ||
} | ||
|
||
// TODO : move in Privacy plugin when available | ||
public function sendRequestToDPO(User $user): bool | ||
{ | ||
$name = $user->getFullName(); | ||
$idUser = $user->getId(); | ||
$dpoEmail = $this->config->getParameter('privacy.dpo.email'); | ||
$locale = $user->getLocale(); | ||
|
||
$subject = $this->translator->trans('account_deletion.subject', [], 'privacy', $locale); | ||
$content = $this->translator->trans('account_deletion.body', ['%name%' => $name, '%id%' => $idUser], 'privacy', $locale); | ||
$body = $this->templateManager->getTemplate('email_layout', ['content' => $content], $locale); | ||
|
||
return $this->mailManager->send($subject, $body, [], null, ['to' => [$dpoEmail]]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.