Skip to content

Commit 451dd7e

Browse files
authored
Apply fixes from StyleCI (pterodactyl#364)
1 parent fe6a190 commit 451dd7e

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

app/Events/Auth/FailedCaptcha.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,31 @@
2929
class FailedCaptcha
3030
{
3131
use SerializesModels;
32-
32+
3333
/**
34-
* The IP that the request originated from.
35-
*
36-
* @var string
37-
*/
34+
* The IP that the request originated from.
35+
*
36+
* @var string
37+
*/
3838
public $ip;
3939

4040
/**
4141
* The domain that was used to try to verify the request with recaptcha api.
42-
*
42+
*
4343
* @var string
4444
*/
4545
public $domain;
46-
46+
4747
/**
48-
* Create a new event instance.
49-
*
50-
* @param string $ip
51-
* @param string $domain
52-
* @return void
53-
*/
48+
* Create a new event instance.
49+
*
50+
* @param string $ip
51+
* @param string $domain
52+
* @return void
53+
*/
5454
public function __construct($ip, $domain)
5555
{
5656
$this->ip = $ip;
5757
$this->domain = $domain;
5858
}
59-
}
59+
}

app/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

app/Http/Middleware/VerifyReCaptcha.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace Pterodactyl\Http\Middleware;
44

55
use Closure;
6-
use Alert;
7-
use \Pterodactyl\Events\Auth\FailedCaptcha;
6+
use Pterodactyl\Events\Auth\FailedCaptcha;
87

98
class VerifyReCaptcha
109
{
@@ -17,8 +16,10 @@ class VerifyReCaptcha
1716
*/
1817
public function handle($request, Closure $next)
1918
{
20-
if (!config('recaptcha.enabled')) return $next($request);
21-
19+
if (! config('recaptcha.enabled')) {
20+
return $next($request);
21+
}
22+
2223
$response_domain = null;
2324

2425
if ($request->has('g-recaptcha-response')) {
@@ -40,20 +41,21 @@ public function handle($request, Closure $next)
4041
// Compare the domain received by google with the app url
4142
$domain_verified = false;
4243
if (config('recaptcha.verify_domain')) {
43-
$matches;
44-
preg_match('/^(?:https?:\/\/)?((?:www\.)?[^:\/\n]+)/', config('app.url'), $matches);
45-
$domain = $matches[1];
46-
$domain_verified = $response_domain === $domain;
44+
$matches;
45+
preg_match('/^(?:https?:\/\/)?((?:www\.)?[^:\/\n]+)/', config('app.url'), $matches);
46+
$domain = $matches[1];
47+
$domain_verified = $response_domain === $domain;
4748
}
4849

49-
if ($result->success && (!config('recaptcha.verify_domain') || $domain_verified)) {
50+
if ($result->success && (! config('recaptcha.verify_domain') || $domain_verified)) {
5051
return $next($request);
5152
}
5253
}
5354
}
54-
55+
5556
// Emit an event and return to the previous view with an error (only the captcha error will be shown!)
5657
event(new FailedCaptcha($request->ip(), $response_domain));
58+
5759
return back()->withErrors(['g-recaptcha-response' => trans('strings.captcha_invalid')])->withInput();
5860
}
5961
}

config/recaptcha.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
return [
44

5-
/**
5+
/*
66
* Enable or disable captchas
77
*/
88
'enabled' => env('RECAPTCHA_ENABLED', true),
99

10-
/**
10+
/*
1111
* Use a custom secret key, we use our public one by default
1212
*/
1313
'secret_key' => env('RECAPTCHA_SECRET_KEY', '6LekAxoUAAAAAPW-PxNWaCLH76WkClMLSa2jImwD'),
1414

15-
/**
15+
/*
1616
* Use a custom website key, we use our public one by default
1717
*/
18-
'website_key' => env('RECAPTCHA_WEBSITE_KEY' ,'6LekAxoUAAAAADjWZJ4ufcDRZBBiH9vfHawqRbup'),
18+
'website_key' => env('RECAPTCHA_WEBSITE_KEY', '6LekAxoUAAAAADjWZJ4ufcDRZBBiH9vfHawqRbup'),
1919

20-
/**
20+
/*
2121
* Domain verification is enabled by default and compares the domain used when solving the captcha
2222
* as public keys can't have domain verification on google's side enabled (obviously).
2323
*/
2424
'verify_domain' => true,
2525

26-
];
26+
];

0 commit comments

Comments
 (0)