Skip to content

Commit 0add007

Browse files
committed
fix(auth): fix disabled button styling and password policy JS serialization
Move .button into auth.scss at the .main_container level so the .button:global(.Mui-disabled) override wins by specificity (0,3,0 vs 0,2,0) rather than depending on source order. Harden shape_pattern and allowed_special_characters in register.blade.php with Js::from(), matching the treatment already applied to the other three passwordPolicy strings. {{ }} encodes & as & inside a script block, which corrupted the regex character class and caused the client to accept passwords the server rejects. Add PasswordPolicyRenderingTest to guard against this class of rendering bug.
1 parent 96d13c2 commit 0add007

5 files changed

Lines changed: 42 additions & 14 deletions

File tree

resources/js/reset_password/reset_password.module.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
text-align: center;
1717
}
1818

19-
.button {
20-
width: 380px;
21-
color: white;
22-
background-color: $base-color-dark;
23-
}
24-
2519
.error_label {
2620
color: #f44336;
2721
font-size: 0.75rem;

resources/js/signup/signup.module.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
text-align: center;
2121
}
2222

23-
.button {
24-
width: 380px;
25-
color: white;
26-
background-color: black;
27-
}
28-
2923
.error_label {
3024
color: #f44336;
3125
font-size: 0.75rem;

resources/styles/auth.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,15 @@
6464
letter-spacing: 0.5em;
6565
}
6666

67+
.button {
68+
width: 380px;
69+
color: white;
70+
background-color: black;
71+
72+
&:global(.Mui-disabled) {
73+
background-color: rgba(0, 0, 0, 0.12);
74+
color: rgba(0, 0, 0, 0.26);
75+
}
76+
}
77+
6778
}

resources/views/auth/register.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
const passwordPolicy = {
2727
min_length: {{ Config::get("auth.password_min_length") }},
2828
max_length: {{ Config::get("auth.password_max_length") }},
29-
shape_pattern: '{{ Config::get("auth.password_shape_pattern") }}',
30-
allowed_special_characters: '{{ Config::get("auth.password_allowed_special_characters") }}',
29+
shape_pattern: {{ Illuminate\Support\Js::from(Config::get("auth.password_shape_pattern")) }},
30+
allowed_special_characters: {{ Illuminate\Support\Js::from(Config::get("auth.password_allowed_special_characters")) }},
3131
allowed_special_characters_text: {{ Illuminate\Support\Js::from(Config::get("auth.password_allowed_special_characters_text")) }},
3232
shape_warning: {{ Illuminate\Support\Js::from(Config::get("auth.password_shape_warning")) }},
3333
shape_list: {{ Illuminate\Support\Js::from(Config::get("auth.password_shape_list")) }}

tests/PasswordPolicyRenderingTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,33 @@ public function test_rendered_reset_pattern_agrees_with_server_pattern(): void
4949
);
5050
}
5151
}
52+
53+
public function test_rendered_signup_pattern_agrees_with_server_pattern(): void
54+
{
55+
$html = view('auth.register', [
56+
'countries' => [],
57+
'client_id' => '',
58+
'redirect_uri' => '',
59+
'errors' => new ViewErrorBag(),
60+
])->render();
61+
62+
$this->assertSame(1, preg_match('/shape_pattern:\s*(.+?),\R/', $html, $m));
63+
64+
// Resolve the \uXXXX escapes a JS parser would resolve in the literal.
65+
// Trim both single quotes ({{ }} format) and double quotes (Js::from format).
66+
$client = preg_replace_callback(
67+
'/\\\\u([0-9a-fA-F]{4})/',
68+
fn ($u) => mb_chr(hexdec($u[1])),
69+
trim($m[1], "\"'")
70+
);
71+
$server = Config::get('auth.password_shape_pattern');
72+
73+
foreach (['Passwordma1', 'Passw0rdabc', ';Passw0rdaa', 'Valid1Pass!'] as $probe) {
74+
$this->assertSame(
75+
(bool) preg_match("/{$server}/", $probe),
76+
(bool) preg_match("/{$client}/", $probe),
77+
"rendered and server patterns disagree on '{$probe}'"
78+
);
79+
}
80+
}
5281
}

0 commit comments

Comments
 (0)