From 3103aca16f35dc9d714fb1692e503b51ef330168 Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Thu, 27 Aug 2015 13:56:58 +1000 Subject: [PATCH] Fixed cases where $request->get was being used instead of $request->input --- api/app/Extensions/Socialite/One/AbstractProvider.php | 10 +++++----- api/app/Extensions/Socialite/Two/ProviderTrait.php | 4 ++-- api/app/Http/Controllers/UserController.php | 10 +++++----- api/tests/integration/ArticleTest.php | 3 --- api/tests/integration/AuthTest.php | 3 ++- api/tests/integration/UserTest.php | 1 + docker/common-services.yml | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/api/app/Extensions/Socialite/One/AbstractProvider.php b/api/app/Extensions/Socialite/One/AbstractProvider.php index 08cd4ee7..75e65126 100644 --- a/api/app/Extensions/Socialite/One/AbstractProvider.php +++ b/api/app/Extensions/Socialite/One/AbstractProvider.php @@ -64,7 +64,7 @@ public function redirect() */ protected function storeReturnUrl(TemporaryCredentials $temp) { - if ($url = $this->request->get('return_url')) { + if ($url = $this->request->input('return_url')) { $key = 'oauth_return_url_'.$temp->getIdentifier(); $this->cache->put($key, $url, ProviderContract::CACHE_TTL); } @@ -77,7 +77,7 @@ protected function storeReturnUrl(TemporaryCredentials $temp) */ public function getCachedReturnUrl() { - $key = 'oauth_return_url_'.$this->request->get('oauth_token'); + $key = 'oauth_return_url_'.$this->request->input('oauth_token'); // If we have no return url stored, redirect back to root page $url = $this->cache->get($key, Config::get('hosts.app')); @@ -95,13 +95,13 @@ protected function getToken() // We have a stateless app without sessions, so we use the cache to // retrieve the temp credentials for man in the middle attack // protection - $key = 'oauth_temp_'.$this->request->get('oauth_token'); + $key = 'oauth_temp_'.$this->request->input('oauth_token'); $temp = $this->cache->get($key, ''); return $this->server->getTokenCredentials( $temp, - $this->request->get('oauth_token'), - $this->request->get('oauth_verifier') + $this->request->input('oauth_token'), + $this->request->input('oauth_verifier') ); } } diff --git a/api/app/Extensions/Socialite/Two/ProviderTrait.php b/api/app/Extensions/Socialite/Two/ProviderTrait.php index 7bd077ea..a3aa43ea 100644 --- a/api/app/Extensions/Socialite/Two/ProviderTrait.php +++ b/api/app/Extensions/Socialite/Two/ProviderTrait.php @@ -33,7 +33,7 @@ public function redirect() */ protected function storeReturnUrl($state) { - if ($url = $this->request->get('return_url')) { + if ($url = $this->request->input('return_url')) { $key = 'oauth_return_url_'.$state; Cache::put($key, $url, ProviderContract::CACHE_TTL); } @@ -46,7 +46,7 @@ protected function storeReturnUrl($state) */ public function getCachedReturnUrl() { - $key = 'oauth_return_url_'.$this->request->get('state'); + $key = 'oauth_return_url_'.$this->request->input('state'); // If we have no return url stored, redirect back to root page $url = Cache::get($key, Config::get('hosts.app')); diff --git a/api/app/Http/Controllers/UserController.php b/api/app/Http/Controllers/UserController.php index 18b4ef8e..2e347e29 100644 --- a/api/app/Http/Controllers/UserController.php +++ b/api/app/Http/Controllers/UserController.php @@ -91,10 +91,10 @@ public function permissions(Request $request) public function putOne(Request $request, $id) { // Extract the credentials - $credential = $request->get('_user_credential', []); + $credential = $request->input('_user_credential', []); // Extract the profile - $profile = $request->get('_user_profile', []); + $profile = $request->input('_user_profile', []); // Set new users to guest $request->merge(['user_type' =>'guest']); @@ -139,7 +139,7 @@ public function patchOne(Request $request, $id) $model = $this->findOrFailEntity($id); // Check if the email is being changed, and initialize confirmation - $email = $request->get('email'); + $email = $request->input('email'); if ($email && $model->email != $email) { $emailConfirmToken = $model->createEmailConfirmToken($email, $model->email); $loginToken = $model->makeLoginToken($model->user_id); @@ -164,7 +164,7 @@ public function patchOne(Request $request, $id) $model->save(); // Extract the profile and update if necessary - $profileUpdateDetails = $request->get('_user_profile', []); + $profileUpdateDetails = $request->input('_user_profile', []); if (!empty($profileUpdateDetails)) { /** @var UserProfile $profile */ $profile = UserProfile::findOrNew($id); // The user profile may not exist for the user @@ -175,7 +175,7 @@ public function patchOne(Request $request, $id) /** @var \Tymon\JWTAuth\JWTAuth $jwtAuth */ // Extract the credentials and update if necessary - $credentialUpdateDetails = $request->get('_user_credential', []); + $credentialUpdateDetails = $request->input('_user_credential', []); if (!empty($credentialUpdateDetails)) { // Invalidate token for the user when user changes their password if ($this->jwtAuth->user()->user_id == $model->user_id) { diff --git a/api/tests/integration/ArticleTest.php b/api/tests/integration/ArticleTest.php index 96a7dfdc..ad544ab7 100644 --- a/api/tests/integration/ArticleTest.php +++ b/api/tests/integration/ArticleTest.php @@ -215,9 +215,6 @@ public function testPostOne() $this->cleanupDiscussions([Article::find($entity->article_id)]); } - /** - * @group error - */ public function testPutOneNew() { $entity = factory(Article::class)->make(); diff --git a/api/tests/integration/AuthTest.php b/api/tests/integration/AuthTest.php index 4315339e..68688f6d 100644 --- a/api/tests/integration/AuthTest.php +++ b/api/tests/integration/AuthTest.php @@ -3,6 +3,7 @@ use App\Models\User; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use Illuminate\Support\Facades\Cache; use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Claims\IssuedAt; use Tymon\JWTAuth\Claims\Issuer; @@ -428,7 +429,7 @@ public function testProviderRedirectReturnUrlOAuthTwo() $key = 'oauth_return_url_'.$array['state']; $url = Cache::get($key); - $this->assertEquals($url, $returnUrl); + $this->assertEquals($returnUrl, $url); } public function testProviderCallbackNoEmail() diff --git a/api/tests/integration/UserTest.php b/api/tests/integration/UserTest.php index b63f60e3..65246c02 100644 --- a/api/tests/integration/UserTest.php +++ b/api/tests/integration/UserTest.php @@ -4,6 +4,7 @@ use App\Models\UserProfile; use Illuminate\Support\Facades\Cache; use App\Models\UserCredential; +use Illuminate\Support\Facades\Hash; /** * Class UserTest diff --git a/docker/common-services.yml b/docker/common-services.yml index 3fbe05c0..7a9b3d33 100644 --- a/docker/common-services.yml +++ b/docker/common-services.yml @@ -54,8 +54,8 @@ web: privileged: true devtools: - image: spira/docker-dev-tools:latest #built version of latest phantomjs (build often fails) -# image: spira/docker-dev-tools:phantomjs-2.0.0 #static binary of phantomjs 2.0.0 +# image: spira/docker-dev-tools:latest #built version of latest phantomjs (build often fails) + image: spira/docker-dev-tools:phantomjs-2.0.0 #static binary of phantomjs 2.0.0 # image: spira/docker-dev-tools:phantomjs-1.9.8 #static bindary of phantomjs 1.9.8 working_dir: /data privileged: true