Skip to content

Commit 11558e3

Browse files
committed
fix: update ip
1 parent 9437a30 commit 11558e3

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

‎config/autoload/ip-address.global.php‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
declare(strict_types=1);
44

5-
// return [
6-
// 'rka' => [
7-
// 'ip_address' => [
8-
// 'check_proxy_headers' => false,
9-
// 'trusted_proxies' => [],
10-
// 'attribute_name' => 'ip_address',
11-
// 'headers_to_inspect' => [],
12-
// ],
13-
// ],
14-
// ];
155

166
// @see https://github.com/akrabat/ip-address-middleware/blob/main/src/IpAddress.php
177
return [
@@ -22,7 +12,7 @@
2212
// Proxy IPs/CIDRs/wildcards trusted to set the headers below.
2313
'trusted_proxies' => [],
2414
// Request attribute the resolved IP is stored under.
25-
'attribute_name' => 'ip_address',
15+
'attribute_name' => 'ipAddress',
2616
// Headers checked, in order, for the client IP.
2717
'headers_to_inspect' => [
2818
// nginx specific

‎src/App/src/Service/ContactService.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private function buildBody(array $data, ?string $ipAddress): string
247247
'Current stack' => $data['stack'],
248248
'Message' => $data['message'],
249249
'Query params' => $data['query'],
250-
'IP address' => $ipAddress ?? '',
250+
'IP address' => $ipAddress,
251251
];
252252

253253
$html = '';

‎test/Unit/App/Handler/PostCreateContactHandlerTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function ipAddressConfig(): array
3939
return [
4040
'check_proxy_headers' => false,
4141
'trusted_proxies' => [],
42-
'attribute_name' => 'ip_address',
42+
'attribute_name' => 'ipAddress',
4343
'headers_to_inspect' => [],
4444
];
4545
}
@@ -223,7 +223,7 @@ public function testFailedTurnstileRerendersWithCaptchaErrorAndSendsNothing(): v
223223

224224
$request = $this->createStub(ServerRequestInterface::class);
225225
$request->method('getParsedBody')->willReturn($data);
226-
$request->method('getAttribute')->willReturnMap([['ip_address', null, '203.0.113.5']]);
226+
$request->method('getAttribute')->willReturnMap([['ipAddress', null, '203.0.113.5']]);
227227

228228
$contactService = $this->createMock(ContactService::class);
229229
$contactService->method('normalize')->willReturn([
@@ -277,7 +277,7 @@ public function testValidSubmissionSendsTheIpAddressFromTheRequestAttribute(): v
277277
{
278278
$request = $this->createStub(ServerRequestInterface::class);
279279
$request->method('getParsedBody')->willReturn($this->validData());
280-
$request->method('getAttribute')->willReturnMap([['ip_address', null, '203.0.113.5']]);
280+
$request->method('getAttribute')->willReturnMap([['ipAddress', null, '203.0.113.5']]);
281281

282282
$contactService = $this->createMock(ContactService::class);
283283
$contactService->method('normalize')->willReturn([

0 commit comments

Comments
 (0)