diff --git a/assets/js/password/showhide.js b/assets/js/password/showhide.js new file mode 100644 index 0000000000..71764e91a1 --- /dev/null +++ b/assets/js/password/showhide.js @@ -0,0 +1,21 @@ +const passwordField = document.querySelector('input[type="password"]'); +const showHidePasswordButton = document.getElementById("password_show_hide"); +const showHidePassword = (event) => { + if (passwordField.type === 'text') { + passwordField.type = 'password'; + showHidePasswordButton.innerHTML="\n" + + " \n" + + " \n" + + " "; + } else { + passwordField.type = 'text'; + showHidePasswordButton.innerHTML="\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " "; + } +} + +showHidePasswordButton.addEventListener("click", showHidePassword); diff --git a/assets/js/signup.js b/assets/js/signup/finalize.js similarity index 91% rename from assets/js/signup.js rename to assets/js/signup/finalize.js index 15b9cbe6f4..408dcc6a67 100644 --- a/assets/js/signup.js +++ b/assets/js/signup/finalize.js @@ -115,4 +115,15 @@ for (let radio of accommodationRadiobuttons) { radio.addEventListener("click", radioHandler) } -console.log(accommodationRadiobuttons) +const showPasswordButton = document.getElementById("password_show_hide"); + +const showHidePassword = (event) => { + console.log("clicked: ", event.target); + if (event.target.type === 'text') { + event.target.type = 'password'; + } else { + event.target.type = 'text'; + } +} + +showPasswordButton.addEventListener("click", showHidePassword); diff --git a/assets/scss/floating_labels.scss b/assets/scss/floating_labels.scss index 725ea126ef..f9148df3df 100644 --- a/assets/scss/floating_labels.scss +++ b/assets/scss/floating_labels.scss @@ -92,6 +92,17 @@ color: #777; } +.form-label-group button { + position: absolute; + top: 12px; + cursor: pointer; + visibility: hidden; +} + +.form-label-group input:not(:placeholder-shown) ~ button { + visibility: visible; +} + /* Fallback for Edge -------------------------------------------------- */ @supports (-ms-ime-align: auto) { diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index 0c4c010d53..f8e3021ad2 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -23,18 +23,20 @@ class SecurityController extends AbstractController * @Route("/login", name="login", defaults={"access_denied_redirect" = "/"})) * @Route("/login", name="security_login", defaults={"access_denied_redirect" = "/"})) * @Route("/login_check", name="security_check", defaults={"access_denied_redirect" = "/"})) - * - * @return Response */ - public function loginAction(AuthenticationUtils $helper) + public function loginAction(AuthenticationUtils $helper): Response { $user = $this->getUser(); if (null !== $user) { return $this->redirectToRoute('homepage'); } - $error = $helper->getLastAuthenticationError(); $lastUsername = $helper->getLastUsername(); + $error = $helper->getLastAuthenticationError(); + + if ($error instanceof AccountMailNotConfirmedException || $error instanceof AccountMailConfirmedException) { + return $this->redirectToRoute('signup_finalize', ['username' => $lastUsername]); + } // $showInvalidCredentialsHint = false; // $showResendConfirmationLink = false; diff --git a/src/Form/SignupFormFinalizeType.php b/src/Form/SignupFormFinalizeType.php index 792dba3a1e..7d6e119ca0 100644 --- a/src/Form/SignupFormFinalizeType.php +++ b/src/Form/SignupFormFinalizeType.php @@ -6,20 +6,13 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\DateTimeType; use Symfony\Component\Form\Extension\Core\Type\DateType; -use Symfony\Component\Form\Extension\Core\Type\EmailType; -use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RangeType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints\Email; -use Symfony\Component\Validator\Constraints\IsTrue; -use Symfony\Component\Validator\Constraints\Length; +use Symfony\Component\Validator\Constraints\LessThan; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\Regex; use Symfony\Contracts\Translation\TranslatorInterface; class SignupFormFinalizeType extends AbstractType @@ -64,6 +57,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) new NotBlank([ 'message' => 'error.birthdate', ]), + new LessThan('-18years'), ], ]) ->add('gender', ChoiceType::class, [ @@ -124,7 +118,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'signup.label.local_events', 'required' => false ]) - ->add('trips_notifications', ChoiceType::class, [ +/* ->add('trips_notifications', ChoiceType::class, [ 'label' => 'label.trips_notifications', 'help' => 'help.trips_notifications', 'expanded' => false, @@ -139,6 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], 'required' => false, ]) +*/ ; } } diff --git a/src/Model/SignupModel.php b/src/Model/SignupModel.php index c81e1d1947..d921d3c0b7 100644 --- a/src/Model/SignupModel.php +++ b/src/Model/SignupModel.php @@ -121,7 +121,7 @@ public function updateMember(Member $member, array $data): void ->setExplanation(0) ->setGettingThere(0) ->setStreetName(0) - ->setRank(1) + ->setRank(0) ->setZip(0) ; diff --git a/src/Pagerfanta/TranslationAdapter.php b/src/Pagerfanta/TranslationAdapter.php index 8300b81e94..43a309cb23 100644 --- a/src/Pagerfanta/TranslationAdapter.php +++ b/src/Pagerfanta/TranslationAdapter.php @@ -41,7 +41,6 @@ public function __construct(Connection $connection, string $locale, string $term ON pi_lang.code = p.code AND pi_lang.shortcode = '{$locale}' AND (pi_lang.isArchived IS NULL OR pi_lang.isArchived = 0) - ORDER BY p.created desc "; if (!empty($term)) { $rawQuery .= " WHERE (p.code LIKE {$term} OR p.Sentence LIKE {$term})"; @@ -53,6 +52,7 @@ public function __construct(Connection $connection, string $locale, string $term , COALESCE(pi_lang.Sentence,pi_dflt.Sentence) AS sentence , COALESCE(pi_lang.created,pi_dflt.created) AS created', $rawQuery); + $this->query .= " ORDER BY created desc"; $this->countQuery = str_replace('*select*', 'COUNT(distinct p.code) AS cnt', $rawQuery); } diff --git a/src/Security/AccountMailConfirmedException.php b/src/Security/AccountMailConfirmedException.php new file mode 100644 index 0000000000..4a73f38697 --- /dev/null +++ b/src/Security/AccountMailConfirmedException.php @@ -0,0 +1,23 @@ +isNotConfirmedYet()) { throw new AccountMailNotConfirmedException(); } + + if ($user->didConfirmMailAddress()) { + throw new AccountMailNotConfirmedException(); + } } } diff --git a/templates/home/home.html.twig b/templates/home/home.html.twig index 1d8cc9a3fa..87fd17e9ad 100644 --- a/templates/home/home.html.twig +++ b/templates/home/home.html.twig @@ -237,6 +237,7 @@ {{ encore_entry_script_tags('home') }} {{ encore_entry_script_tags('jquery_ui') }} +{{ encore_entry_script_tags('password/showhide') }}