Skip to content

Commit

Permalink
Fixed cases where $request->get was being used instead of $request->i…
Browse files Browse the repository at this point in the history
…nput
  • Loading branch information
zakhenry committed Aug 27, 2015
1 parent 10d2859 commit 3103aca
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
10 changes: 5 additions & 5 deletions api/app/Extensions/Socialite/One/AbstractProvider.php
Expand Up @@ -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);
}
Expand All @@ -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'));
Expand All @@ -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')
);
}
}
4 changes: 2 additions & 2 deletions api/app/Extensions/Socialite/Two/ProviderTrait.php
Expand Up @@ -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);
}
Expand All @@ -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'));
Expand Down
10 changes: 5 additions & 5 deletions api/app/Http/Controllers/UserController.php
Expand Up @@ -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']);
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions api/tests/integration/ArticleTest.php
Expand Up @@ -215,9 +215,6 @@ public function testPostOne()
$this->cleanupDiscussions([Article::find($entity->article_id)]);
}

/**
* @group error
*/
public function testPutOneNew()
{
$entity = factory(Article::class)->make();
Expand Down
3 changes: 2 additions & 1 deletion api/tests/integration/AuthTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions api/tests/integration/UserTest.php
Expand Up @@ -4,6 +4,7 @@
use App\Models\UserProfile;
use Illuminate\Support\Facades\Cache;
use App\Models\UserCredential;
use Illuminate\Support\Facades\Hash;

/**
* Class UserTest
Expand Down
4 changes: 2 additions & 2 deletions docker/common-services.yml
Expand Up @@ -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
Expand Down

0 comments on commit 3103aca

Please sign in to comment.