|
12 | 12 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
13 | 13 | use Pterodactyl\Http\Requests\Api\Remote\SftpAuthenticationFormRequest; |
14 | 14 |
|
15 | | -class SftpController extends Controller |
| 15 | +class SftpAuthenticationController extends Controller |
16 | 16 | { |
17 | 17 | use ThrottlesLogins; |
18 | 18 |
|
@@ -40,9 +40,12 @@ public function __construct(AuthenticateUsingPasswordService $authenticationServ |
40 | 40 | * |
41 | 41 | * @throws \Pterodactyl\Exceptions\Model\DataValidationException |
42 | 42 | */ |
43 | | - public function index(SftpAuthenticationFormRequest $request): JsonResponse |
| 43 | + public function __invoke(SftpAuthenticationFormRequest $request): JsonResponse |
44 | 44 | { |
| 45 | + // Reverse the string to avoid issues with usernames that contain periods. |
45 | 46 | $parts = explode('.', strrev($request->input('username')), 2); |
| 47 | + |
| 48 | + // Unreverse the strings after parsing them apart. |
46 | 49 | $connection = [ |
47 | 50 | 'username' => strrev(array_get($parts, 1)), |
48 | 51 | 'server' => strrev(array_get($parts, 0)), |
@@ -86,6 +89,8 @@ public function index(SftpAuthenticationFormRequest $request): JsonResponse |
86 | 89 | */ |
87 | 90 | protected function throttleKey(Request $request) |
88 | 91 | { |
89 | | - return strtolower(array_get(explode('.', $request->input('username')), 0) . '|' . $request->ip()); |
| 92 | + $username = explode('.', strrev($request->input('username', ''))); |
| 93 | + |
| 94 | + return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); |
90 | 95 | } |
91 | 96 | } |
0 commit comments