Skip to content

Commit 3b4a096

Browse files
authored
Merge pull request pterodactyl#2684 from mattmalec/develop
Fix API 500 error
2 parents 0c8b710 + 2f2d105 commit 3b4a096

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/Http/Middleware/Api/AuthenticateIPAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function handle(Request $request, Closure $next)
2929
}
3030

3131
$find = new IP($request->ip());
32-
foreach (json_decode($model->allowed_ips) as $ip) {
32+
foreach ($model->allowed_ips as $ip) {
3333
if (Range::parse($ip)->contains($find)) {
3434
return $next($request);
3535
}

tests/Unit/Http/Middleware/Api/AuthenticateIPAccessTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testWithNoIPRestrictions()
2626
*/
2727
public function testWithValidIP()
2828
{
29-
$model = factory(ApiKey::class)->make(['allowed_ips' => '["127.0.0.1"]']);
29+
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]);
3030
$this->setRequestAttribute('api_key', $model);
3131

3232
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('127.0.0.1');
@@ -39,7 +39,7 @@ public function testWithValidIP()
3939
*/
4040
public function testValidIPAgainstCIDRRange()
4141
{
42-
$model = factory(ApiKey::class)->make(['allowed_ips' => '["192.168.1.1/28"]']);
42+
$model = factory(ApiKey::class)->make(['allowed_ips' => ['192.168.1.1/28']]);
4343
$this->setRequestAttribute('api_key', $model);
4444

4545
$this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('192.168.1.15');
@@ -55,7 +55,7 @@ public function testWithInvalidIP()
5555
{
5656
$this->expectException(AccessDeniedHttpException::class);
5757

58-
$model = factory(ApiKey::class)->make(['allowed_ips' => '["127.0.0.1"]']);
58+
$model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]);
5959
$this->setRequestAttribute('api_key', $model);
6060

6161
$this->request->shouldReceive('ip')->withNoArgs()->twice()->andReturn('127.0.0.2');

0 commit comments

Comments
 (0)