Skip to content

Commit dd251d9

Browse files
committed
Merge branch 'nesges/development' into development
2 parents 7b3b28d + 5c28bcf commit dd251d9

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

app/Access/Controllers/RegisterController.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,13 @@
1515

1616
class RegisterController extends Controller
1717
{
18-
protected SocialDriverManager $socialDriverManager;
19-
protected RegistrationService $registrationService;
20-
protected LoginService $loginService;
21-
22-
/**
23-
* Create a new controller instance.
24-
*/
2518
public function __construct(
26-
SocialDriverManager $socialDriverManager,
27-
RegistrationService $registrationService,
28-
LoginService $loginService
19+
protected SocialDriverManager $socialDriverManager,
20+
protected RegistrationService $registrationService,
21+
protected LoginService $loginService
2922
) {
3023
$this->middleware('guest');
3124
$this->middleware('guard:standard');
32-
33-
$this->socialDriverManager = $socialDriverManager;
34-
$this->registrationService = $registrationService;
35-
$this->loginService = $loginService;
3625
}
3726

3827
/**
@@ -87,6 +76,8 @@ protected function validator(array $data): ValidatorContract
8776
'name' => ['required', 'min:2', 'max:100'],
8877
'email' => ['required', 'email', 'max:255', 'unique:users'],
8978
'password' => ['required', Password::default()],
79+
// Basic honey for bots that must not be filled in
80+
'username' => ['prohibited'],
9081
]);
9182
}
9283
}

resources/sass/_forms.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,20 @@ input[type=color] {
389389
}
390390
}
391391

392+
.form-group.ambrosia-container, .form-group.ambrosia-container * {
393+
position:absolute !important;
394+
height:1px !important;
395+
width:1px !important;
396+
margin:-1px !important;
397+
padding:0 !important;
398+
background:transparent !important;
399+
color:transparent !important;
400+
border:none !important;
401+
overflow: hidden !important;
402+
clip: rect(0,0,0,0) !important;
403+
white-space: nowrap !important;
404+
}
405+
392406
.title-input input[type="text"] {
393407
display: block;
394408
width: 100%;
@@ -538,4 +552,4 @@ input.shortcut-input {
538552
width: auto;
539553
max-width: 120px;
540554
height: auto;
541-
}
555+
}

resources/views/auth/register.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
<form action="{{ url("/register") }}" method="POST" class="mt-l stretch-inputs">
1414
{!! csrf_field() !!}
1515

16+
{{-- Simple honeypot field --}}
17+
<div class="form-group ambrosia-container" aria-hidden="true">
18+
<label for="username">{{ trans('auth.name') }}</label>
19+
@include('form.text', ['name' => 'username'])
20+
</div>
21+
1622
<div class="form-group">
17-
<label for="email">{{ trans('auth.name') }}</label>
23+
<label for="name">{{ trans('auth.name') }}</label>
1824
@include('form.text', ['name' => 'name'])
1925
</div>
2026

tests/Auth/RegistrationTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,23 @@ public function test_registration_validation()
184184
$resp->assertSee('The email must be a valid email address.');
185185
$resp->assertSee('The password must be at least 8 characters.');
186186
}
187+
188+
public function test_registration_simple_honeypot_active()
189+
{
190+
$this->setSettings(['registration-enabled' => 'true']);
191+
192+
$resp = $this->get('/register');
193+
$this->withHtml($resp)->assertElementExists('form input[name="username"]');
194+
195+
$resp = $this->post('/register', [
196+
'name' => 'Barry',
197+
'email' => 'barrybot@example.com',
198+
'password' => 'barryIsTheBestBot',
199+
'username' => 'MyUsername'
200+
]);
201+
$resp->assertRedirect('/register');
202+
203+
$resp = $this->followRedirects($resp);
204+
$this->withHtml($resp)->assertElementExists('form input[name="username"].text-neg');
205+
}
187206
}

0 commit comments

Comments
 (0)