Skip to content

Commit 8415a52

Browse files
Fix some issues with the signup states. Redirect to finalize signup if applicable. Sort translations correctly. Show/hide password.
1 parent d65246b commit 8415a52

15 files changed

+133
-34
lines changed

assets/js/password/showhide.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const passwordField = document.querySelector('input[type="password"]');
2+
const showHidePasswordButton = document.getElementById("password_show_hide");
3+
const showHidePassword = (event) => {
4+
if (passwordField.type === 'text') {
5+
passwordField.type = 'password';
6+
showHidePasswordButton.innerHTML="<svg class=\"\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n" +
7+
" <path class=\"block\" d=\"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z\"></path>\n" +
8+
" <circle class=\"block\" cx=\"12\" cy=\"12\" r=\"3\"></circle>\n" +
9+
" </svg>";
10+
} else {
11+
passwordField.type = 'text';
12+
showHidePasswordButton.innerHTML="<svg class=\"\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n" +
13+
" <path class=\"\" d=\"M9.88 9.88a3 3 0 1 0 4.24 4.24\"></path>\n" +
14+
" <path class=\"\" d=\"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68\"></path>\n" +
15+
" <path class=\"\" d=\"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61\"></path>\n" +
16+
" <line class=\"\" x1=\"2\" x2=\"22\" y1=\"2\" y2=\"22\"></line>\n" +
17+
" </svg>";
18+
}
19+
}
20+
21+
showHidePasswordButton.addEventListener("click", showHidePassword);

assets/js/signup.js assets/js/signup/finalize.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,15 @@ for (let radio of accommodationRadiobuttons) {
115115
radio.addEventListener("click", radioHandler)
116116
}
117117

118-
console.log(accommodationRadiobuttons)
118+
const showPasswordButton = document.getElementById("password_show_hide");
119+
120+
const showHidePassword = (event) => {
121+
console.log("clicked: ", event.target);
122+
if (event.target.type === 'text') {
123+
event.target.type = 'password';
124+
} else {
125+
event.target.type = 'text';
126+
}
127+
}
128+
129+
showPasswordButton.addEventListener("click", showHidePassword);

assets/scss/floating_labels.scss

+11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@
9292
color: #777;
9393
}
9494

95+
.form-label-group button {
96+
position: absolute;
97+
top: 12px;
98+
cursor: pointer;
99+
visibility: hidden;
100+
}
101+
102+
.form-label-group input:not(:placeholder-shown) ~ button {
103+
visibility: visible;
104+
}
105+
95106
/* Fallback for Edge
96107
-------------------------------------------------- */
97108
@supports (-ms-ime-align: auto) {

src/Controller/SecurityController.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ class SecurityController extends AbstractController
2323
* @Route("/login", name="login", defaults={"access_denied_redirect" = "/"}))
2424
* @Route("/login", name="security_login", defaults={"access_denied_redirect" = "/"}))
2525
* @Route("/login_check", name="security_check", defaults={"access_denied_redirect" = "/"}))
26-
*
27-
* @return Response
2826
*/
29-
public function loginAction(AuthenticationUtils $helper)
27+
public function loginAction(AuthenticationUtils $helper): Response
3028
{
3129
$user = $this->getUser();
3230
if (null !== $user) {
3331
return $this->redirectToRoute('homepage');
3432
}
3533

36-
$error = $helper->getLastAuthenticationError();
3734
$lastUsername = $helper->getLastUsername();
35+
$error = $helper->getLastAuthenticationError();
36+
37+
if ($error instanceof AccountMailNotConfirmedException || $error instanceof AccountMailConfirmedException) {
38+
return $this->redirectToRoute('signup_finalize', ['username' => $lastUsername]);
39+
}
3840

3941
// $showInvalidCredentialsHint = false;
4042
// $showResendConfirmationLink = false;

src/Form/SignupFormFinalizeType.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@
66
use Symfony\Component\Form\AbstractType;
77
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
88
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
9-
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
109
use Symfony\Component\Form\Extension\Core\Type\DateType;
11-
use Symfony\Component\Form\Extension\Core\Type\EmailType;
12-
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
1310
use Symfony\Component\Form\Extension\Core\Type\RangeType;
1411
use Symfony\Component\Form\Extension\Core\Type\TextType;
1512
use Symfony\Component\Form\FormBuilderInterface;
16-
use Symfony\Component\OptionsResolver\OptionsResolver;
17-
use Symfony\Component\Validator\Constraints\Email;
18-
use Symfony\Component\Validator\Constraints\IsTrue;
19-
use Symfony\Component\Validator\Constraints\Length;
13+
use Symfony\Component\Validator\Constraints\LessThan;
2014
use Symfony\Component\Validator\Constraints\NotBlank;
2115
use Symfony\Component\Validator\Constraints\NotNull;
22-
use Symfony\Component\Validator\Constraints\Regex;
2316
use Symfony\Contracts\Translation\TranslatorInterface;
2417

2518
class SignupFormFinalizeType extends AbstractType
@@ -64,6 +57,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6457
new NotBlank([
6558
'message' => 'error.birthdate',
6659
]),
60+
new LessThan('-18years'),
6761
],
6862
])
6963
->add('gender', ChoiceType::class, [
@@ -124,7 +118,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
124118
'label' => 'signup.label.local_events',
125119
'required' => false
126120
])
127-
->add('trips_notifications', ChoiceType::class, [
121+
/* ->add('trips_notifications', ChoiceType::class, [
128122
'label' => 'label.trips_notifications',
129123
'help' => 'help.trips_notifications',
130124
'expanded' => false,
@@ -139,6 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
139133
],
140134
'required' => false,
141135
])
136+
*/
142137
;
143138
}
144139
}

src/Model/SignupModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function updateMember(Member $member, array $data): void
121121
->setExplanation(0)
122122
->setGettingThere(0)
123123
->setStreetName(0)
124-
->setRank(1)
124+
->setRank(0)
125125
->setZip(0)
126126
;
127127

src/Pagerfanta/TranslationAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function __construct(Connection $connection, string $locale, string $term
4141
ON pi_lang.code = p.code
4242
AND pi_lang.shortcode = '{$locale}'
4343
AND (pi_lang.isArchived IS NULL OR pi_lang.isArchived = 0)
44-
ORDER BY p.created desc
4544
";
4645
if (!empty($term)) {
4746
$rawQuery .= " WHERE (p.code LIKE {$term} OR p.Sentence LIKE {$term})";
@@ -53,6 +52,7 @@ public function __construct(Connection $connection, string $locale, string $term
5352
, COALESCE(pi_lang.Sentence,pi_dflt.Sentence) AS sentence
5453
, COALESCE(pi_lang.created,pi_dflt.created) AS created', $rawQuery);
5554

55+
$this->query .= " ORDER BY created desc";
5656
$this->countQuery = str_replace('*select*', 'COUNT(distinct p.code) AS cnt', $rawQuery);
5757
}
5858

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* Created by PhpStorm.
5+
* User: bla
6+
* Date: 24.08.2018
7+
* Time: 11:59.
8+
*/
9+
10+
namespace App\Security;
11+
12+
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
13+
14+
class AccountMailConfirmedException extends CustomUserMessageAccountStatusException
15+
{
16+
/**
17+
* {@inheritdoc}
18+
*/
19+
public function getMessageKey(): string
20+
{
21+
return 'login.mail.confirmed';
22+
}
23+
}

src/Security/UserChecker.php

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function checkPreAuth(UserInterface $user)
3131
/**
3232
* @throws AccountExpiredException
3333
* @throws AccountSuspendedException
34+
* @throws AccountMailConfirmedException
3435
* @throws AccountMailNotConfirmedException
3536
*/
3637
public function checkPostAuth(UserInterface $user)
@@ -50,5 +51,9 @@ public function checkPostAuth(UserInterface $user)
5051
if ($user->isNotConfirmedYet()) {
5152
throw new AccountMailNotConfirmedException();
5253
}
54+
55+
if ($user->didConfirmMailAddress()) {
56+
throw new AccountMailNotConfirmedException();
57+
}
5358
}
5459
}

templates/home/home.html.twig

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
</div>
238238
{{ encore_entry_script_tags('home') }}
239239
{{ encore_entry_script_tags('jquery_ui') }}
240+
{{ encore_entry_script_tags('password/showhide') }}
240241
<script>
241242
window.addEventListener("load", function () {
242243
let locale = document.getElementsByTagName('html')[0].getAttribute('lang');

templates/login_form_navbar.html.twig

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
</div>
77
<div class="form-label-group my-1 ml-md-1 mr-0 m-lg-1">
88
<input class="form-control" type="password" id="_password_1" name="_password" placeholder="{{ 'login.password'|trans }}">
9+
<button type="button" id="password_show_hide" class="u-absolute u-text-gray-50 u-border-0 u-bg-white u-h-full u-top-0 u-end-0" style="height: 38px; margin: 1px; background-color: transparent">
10+
<svg class="" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
11+
<path class="block" d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path>
12+
<circle class="block" cx="12" cy="12" r="3"></circle>
13+
</svg>
14+
</button>
915
<label for="_password_1">{{ 'password'|trans }}</label>
1016
</div>
1117
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">

templates/security/login.html.twig

+10-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,15 @@
128128
</div>
129129
<div class="o-form-group">
130130
<label for="login-p">{{ 'password' | trans }}</label>
131-
<input type="password" id="login-p" name="_password" class="o-input">
131+
<div class="u-relative">
132+
<input type="password" id="login-p" name="_password" class="o-input">
133+
<button type="button" id="password_show_hide" class="u-absolute u-text-gray-50 u-border-0 u-bg-white u-h-full u-top-0 u-end-0" style="height: 38px; margin: 1px; background-color: transparent">
134+
<svg class="" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
135+
<path class="block" d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path>
136+
<circle class="block" cx="12" cy="12" r="3"></circle>
137+
</svg>
138+
</button>
139+
</div>
132140
</div>
133141
<div class="o-checkbox u-flex u-items-center u-my-8">
134142
<input type="checkbox"
@@ -190,5 +198,6 @@
190198
{% endblock content %}
191199
{% include 'footer.html.twig' %}
192200
{{ encore_entry_script_tags('bewelcome') }}
201+
{{ encore_entry_script_tags('password/showhide') }}
193202
</body>
194203
</html>

templates/signup/finalize.html.twig

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'base-lite.html.twig' %}
22

33
{% block javascripts %}
4-
{{ encore_entry_script_tags('signup/signup') }}
4+
{{ encore_entry_script_tags('signup/finalize') }}
55
<script type="application/javascript">
66
const accommodation = "{{ finalize.accommodation.vars.full_name }}";
77
const markers = [
@@ -21,7 +21,7 @@
2121
{% endblock %}
2222

2323
{% block stylesheets %}
24-
{{ encore_entry_link_tags('signup/signup') }}
24+
{{ encore_entry_link_tags('signup/finalize') }}
2525
{% endblock stylesheets %}
2626

2727
{% block content %}
@@ -109,27 +109,22 @@
109109
{% do finalize.accommodation.setRendered %}
110110

111111
<div id="hosting_interest" class="
112-
{%- if finalize.accommodation.vars.value == finalize.accommodation.children[1].vars.value %}u-block{% else %}u-hidden{% endif -%}
113-
">
112+
{%- if finalize.accommodation.vars.value == finalize.accommodation.children[1].vars.value %}u-block{% else %}u-hidden{% endif %} u-mt-8">
114113
{{ form_label(finalize.hosting_interest) }}
115114
{{ form_widget(finalize.hosting_interest) }}
116115
<div class="range text-center u-mt-16">
117116
<p class="rangeSlider__value-output">{{ 'hosting.interest.set'|trans }}</p>
118117
</div>
119118
{{ form_help(finalize.hosting_interest) }}
120119
</div>
121-
<div class="u-flex u-justify-end">
122-
<input type="submit" class="o-button" value="{{ 'signup.activate'|trans }}">
120+
<div class="u-mt-8">
121+
<p class="u-text-18 u-mb-8 u-font-600">{{ 'signup.optional'|trans }}</p>
122+
{{ form_row(finalize.newsletters) }}
123+
{{ form_row(finalize.local_events) }}
124+
{# {{ form_row(finalize.trips_notifications) }} #}
123125
</div>
124-
125-
<p class="u-text-18 u-mb-8">{{ 'signup.optional'|trans }}</p>
126-
{{ form_row(finalize.newsletters) }}
127-
{{ form_row(finalize.local_events) }}
128-
{{ form_row(finalize.trips_notifications) }}
129-
130-
{{ form_rest(finalize) }}
131-
<div class="u-flex u-justify-end">
132-
<input type="submit" class="o-button o-button--outline" value="{{ 'signup.activate'|trans }}">
126+
<div class="u-flex u-justify-end u-mt-8">
127+
<input type="submit" class="o-button" value="{{ 'signup.activate'|trans }}">
133128
</div>
134129

135130
{{ form_end(finalize) }}

templates/signup/first.step.html.twig

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
BeWelcome - {{ 'signup' | trans }}
66
{% endblock title %}
77

8+
{% block javascripts %}
9+
{{ encore_entry_script_tags('password/showhide') }}
10+
{% endblock javascripts %}
11+
812
{% block content %}
913
<h1>{{ 'signup'|trans }}</h1>
1014
{{ form_start(signup, { 'attr': { autocomplete: 'off' } }) }}
@@ -18,7 +22,22 @@
1822
{{ form_row(signup.email, {'attr': {autofocus: 'autofocus'}}) }}
1923
{% endif %}
2024

21-
{{ form_row(signup.password) }}
25+
<div class="o-form-group u-mt-8">
26+
<label for="{{ signup.password.vars.id }}">{{ signup.password.vars.label|trans }}</label>
27+
<div class="u-relative">
28+
<input type="password" id="{{ signup.password.vars.id }}"
29+
name="{{ signup.password.vars.name }}"
30+
placeholder="{{ signup.password.vars.label|trans }}"
31+
aria-describedby="{{ signup.password.vars.id }}_help" class="o-input">
32+
<button type="button" id="password_show_hide" class="u-absolute u-text-gray-50 u-border-0 u-bg-white u-h-full u-top-0 u-end-0" style="height: 38px; margin: 1px; background-color: transparent">
33+
<svg class="" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
34+
<path class="block" d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path>
35+
<circle class="block" cx="12" cy="12" r="3"></circle>
36+
</svg>
37+
</button>
38+
</div>
39+
<small id="{{ signup.password.vars.id }}_help" class="form-text text-muted">{{ signup.password.vars.help|trans }}</small></div>
40+
{% do signup.password.setRendered %}
2241

2342
{{ form_row(signup.terms_privacy) }}
2443
<div class="u-flex u-justify-end">

webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Encore
2525
.addEntry('bewelcome', './assets/js/bewelcome.js')
2626
.addEntry('home', './assets/js/home.js')
2727
.addEntry('jquery_ui', './assets/js/jquery_ui.js')
28-
.addEntry('signup/signup', './assets/js/signup.js')
28+
.addEntry('password/showhide', './assets/js/password/showhide.js')
29+
.addEntry('signup/finalize', './assets/js/signup/finalize.js')
2930
.addEntry('members/editmyprofile', './assets/js/editmyprofile.js')
3031
.addEntry('landing', './assets/js/landing/landing.js')
3132
.addEntry('search/loadpicker', './assets/js/search/loadpicker.js')

0 commit comments

Comments
 (0)