Skip to content

Commit

Permalink
Removed functionality for retrieving twitter access token #922
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors Keuninkx committed Mar 29, 2024
1 parent c04d719 commit ce0754b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
28 changes: 0 additions & 28 deletions app/src/User/AuthApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,4 @@ public function login($username, $password, $clientId, $clientSecret)
}
return false;
}

/**
* Send Twitter verification token to the API to log us in
*
* @param string $clientId OAuth client ID
* @param string $clientSecret OAuth client secret
*/
public function verifyTwitter($clientId, $clientSecret, $token, $verifier)
{
$url = $this->baseApiUrl . '/v2.1/twitter/token';
$params = [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'token' => $token,
'verifier' => $verifier,
];

list($status, $result, $headers) = $this->apiPost($url, $params);
if ($result) {
$data = json_decode($result);
if ($data) {
if (isset($data->access_token)) {
return $data;
}
}
}
return false;
}
}
23 changes: 0 additions & 23 deletions app/src/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected function defineRoutes(\Slim\Slim $app)
->via('GET', 'POST')->name('user-password-reset');
$app->map('/user/new-password', [$this, 'newPassword'])
->via('GET', 'POST')->name('user-new-password');
$app->get('/user/twitter-access', [$this, 'accessTokenFromTwitter'])->name('twitter-callback');
$app->get('/user/:username', [$this, 'profile'])->name('user-profile');
$app->get('/user/:username/talks', [$this, 'profileTalks'])->name('user-profile-talks');
$app->get('/user/:username/events', [$this, 'profileEvents'])->name('user-profile-events');
Expand Down Expand Up @@ -785,28 +784,6 @@ public function newPassword()
);
}

/**
* The callback URL should point to here
*/
public function accessTokenFromTwitter()
{
$config = $this->application->config('oauth');
$request = $this->application->request();

// pass verification to the API so we can log in
$clientId = $config['client_id'];
$clientSecret = $config['client_secret'];

// handle incoming vars
$token = $request->get('oauth_token');
$verifier = $request->get('oauth_verifier');

$authApi = $this->application->container->get(AuthApi::class);
$result = $authApi->verifyTwitter($clientId, $clientSecret, $token, $verifier);

$this->handleLogin($result);
}

/**
* Process a user login result. If result is false, then we failed, otherwise
* update the session.
Expand Down

0 comments on commit ce0754b

Please sign in to comment.