diff --git a/config/packages/dev/web_profiler.yaml b/config/packages/dev/web_profiler.yaml index e92166a7fdaecfc6420ac429ba185e48b3199926..fd2242410469b02b8e7f3c44daa29575d4c7e425 100644 --- a/config/packages/dev/web_profiler.yaml +++ b/config/packages/dev/web_profiler.yaml @@ -1,6 +1,6 @@ web_profiler: toolbar: true - intercept_redirects: false + intercept_redirects: true framework: profiler: { only_exceptions: false } diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 7853e9ed52b8997cf8ea4c7252c6476a7eb41794..07b9ab32fe1e8a9140a52ded29cdd808a6f1487d 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -11,6 +11,7 @@ framework: cookie_secure: auto cookie_samesite: lax storage_factory_id: session.storage.factory.native + enabled: true #esi: true #fragments: true diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index f9f4cc539ba6fee13b96c7ee0a6f1d861785a3be..3be7d524674db9b4ce4d158f055ebaff0b6fa1d9 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,5 +1,6 @@ twig: default_path: '%kernel.project_dir%/templates' + form_themes: ['bootstrap_5_layout.html.twig'] when@test: twig: diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 76e457106c99e57ef87634b385015ff586250ddc..f349e7a526aab581d4a84db960f09cbb3ceb22c3 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -10,6 +10,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Mime\Address; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; @@ -19,10 +20,12 @@ use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; class RegistrationController extends AbstractController { private EmailVerifier $emailVerifier; + private RequestStack $requestStack; - public function __construct(EmailVerifier $emailVerifier) + public function __construct(EmailVerifier $emailVerifier, RequestStack $requestStack) { $this->emailVerifier = $emailVerifier; + $this->requestStack = $requestStack; } /** @@ -57,9 +60,13 @@ class RegistrationController extends AbstractController ->subject('Please Confirm your Email') ->htmlTemplate('registration/confirmation_email.html.twig') ); - // do anything else you need here, like send an email - return $this->redirectToRoute('_profiler_home'); + // do anything else you need here, like send an email + // return $this->redirectToRoute('app_login'); + $this->requestStack->getSession()->set('userid', $user->getId()); + return $this->redirectToRoute('app_register_mail_sent'); +// $message = 'An email has been sent to '. $user->getEmail() .'. It contains an activation link you must click to activate your account.'; +// $this->addFlash('success', $message); } return $this->render('registration/register.html.twig', [ @@ -98,4 +105,16 @@ class RegistrationController extends AbstractController return $this->redirectToRoute('app_register'); } + + /** + * @Route("/register_mail_sent", name="app_register_mail_sent") + */ + public function mailSentMessage(UserRepository $userRepository){ + $userid = $this->requestStack->getSession()->get('userid'); + $user = $userRepository->find($userid); + + return $this->render('registration/register_mail_sent.html.twig', [ + 'user' => $user, + ]); + } } diff --git a/templates/registration.base.html.twig b/templates/registration.base.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..dbefa8d2d93f69c5cbe052a164d6211ffd800dca --- /dev/null +++ b/templates/registration.base.html.twig @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="UTF-8"> + <title>{% block title %}MemoRekall{% endblock %}</title> + {# Run `composer require symfony/webpack-encore-bundle` + and uncomment the following Encore helpers to start using Symfony UX #} + {% block stylesheets %} + {{ encore_entry_link_tags('app') }} + {% endblock %} + + {% block javascripts %} + {{ encore_entry_script_tags('app') }} + {% endblock %} +</head> +<body class="container"> +<div class="d-flex flex-row justify-content-center mb-5"> + <div class="d-flex flex-column"> + <a href="/my_capsules"><img id="header-memorekall-logo" class="memorekall-logo" src="{{ asset('build/images/MemoRekall.png') }}"></a> + <div class="d-flex flex-row justify-content-center"> + <a href="/login" class="btn btn-primary m-2 px-4 py-3" >LOG IN</a> + <a href="/register" class="btn btn-primary m-2 px-4 py-3" >SIGN IN</a> + </div> + </div> +</div> +{% block body %}{% endblock %} +</body> +</html> \ No newline at end of file diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig index 7ea0360f1d6a588d6f345e041228341efd84c4c5..c2d1417baa1474bd637c1b94de882f5e06c80765 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -1,23 +1,21 @@ -{% extends 'base.html.twig' %} +{% extends 'registration.base.html.twig' %} {% block title %}Register{% endblock %} {% block body %} - <div class="container d-flex flex-column justify-content-center"> + <div class="d-flex flex-column justify-content-center"> {% for flashError in app.flashes('verify_email_error') %} - <div class="alert alert-danger" role="alert">{{ flashError }}</div> + <div class="alert alert-danger col-6 mx-auto my-5 h1" role="alert">{{ flashError }}</div> {% endfor %} - {% for flashError in app.flashes('success') %} - <div class="alert alert-danger" role="alert">{{ flashError }}</div> + {% for flashMessage in app.flashes('success') %} + <div class="alert alert-warning col-6 mx-auto my-5 h1" role="alert" >{{ flashMessage }}</div> {% endfor %} - <div> </div> {{ form_start(registrationForm, {'attr': {'class': 'd-flex flex-column justify-content-center'}}) }} - {{ form_errors(registrationForm) }} - {{ form_row(registrationForm.firstName) }} + {{ form_row(registrationForm.firstName) }} {{ form_row(registrationForm.lastName) }} {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.plainPassword, { diff --git a/templates/registration/register_mail_sent.html.twig b/templates/registration/register_mail_sent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..4acd445144a067d71cce42e6335616e0cac97022 --- /dev/null +++ b/templates/registration/register_mail_sent.html.twig @@ -0,0 +1,10 @@ +{% extends 'registration.base.html.twig' %} +{% block title %}Mail registration sent{% endblock %} + +{% block body %} + <div class="container d-flex flex-row justify-content-center"> + <div class="col-6"> + <p class="alert">An email has been sent to {{ user.getEmail() }} . It contains an activation link you must click to activate your account</p> + </div> + </div> +{% endblock %} \ No newline at end of file