From d5c00d0eb34692ca36109ed0f0d75ea675ce6206 Mon Sep 17 00:00:00 2001 From: Sjors Keuninkx Date: Fri, 29 Mar 2024 08:31:19 +0100 Subject: [PATCH 1/4] Removed facebook login #922 --- app/src/View/FunctionsExtension.php | 27 --------------------------- app/templates/_common/login.html.twig | 3 +-- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/app/src/View/FunctionsExtension.php b/app/src/View/FunctionsExtension.php index dbc160231..8f5772bb8 100644 --- a/app/src/View/FunctionsExtension.php +++ b/app/src/View/FunctionsExtension.php @@ -152,33 +152,6 @@ function ($start, $end, $format = 'd.m.Y', $separator = ' - ') { } }), - /** - * Create link to log in with Facebook - */ - new Twig_SimpleFunction( - 'facebookLoginUrl', - function () use ($app) { - if (!$app->config('facebook') || empty($app->config('facebook')['app_id'])) { - // app_id isn't configured - return ''; - } - - $req = $app->request(); - $redirectUrl = $req->getUrl(); - $redirectUrl .= $app->urlFor('facebook-callback'); - - $url = 'https://www.facebook.com/dialog/oauth?'; - $url .= http_build_query([ - 'scope' => 'email', - 'client_id' => $app->config('facebook')['app_id'], - 'redirect_uri' => $redirectUrl, - ]); - - return $url; - }, - ['is_safe' => ['html']] - ), - /** * Create a link to download a QR-Code for the given URL */ diff --git a/app/templates/_common/login.html.twig b/app/templates/_common/login.html.twig index 1c5b6242b..623c10d1b 100644 --- a/app/templates/_common/login.html.twig +++ b/app/templates/_common/login.html.twig @@ -20,7 +20,6 @@
Already registered?
Sign in with Twitter - Log In with Facebook
Problems logging in?
@@ -29,4 +28,4 @@ Forgotten username
- + \ No newline at end of file From f68b31049f13ff613414127fe9817ef1f5addefe Mon Sep 17 00:00:00 2001 From: Sjors Keuninkx Date: Fri, 29 Mar 2024 08:32:21 +0100 Subject: [PATCH 2/4] Removed functionality for retrieving facebook access token #922 --- app/src/User/AuthApi.php | 28 ---------------------------- app/src/User/UserController.php | 22 ---------------------- 2 files changed, 50 deletions(-) diff --git a/app/src/User/AuthApi.php b/app/src/User/AuthApi.php index ee9a41dc6..24d2b2755 100644 --- a/app/src/User/AuthApi.php +++ b/app/src/User/AuthApi.php @@ -89,32 +89,4 @@ public function verifyTwitter($clientId, $clientSecret, $token, $verifier) } return false; } - - /** - * Send Facebook verification code to the API to log us in - * - * @param string $clientId OAuth client ID - * @param string $clientSecret OAuth client secret - * @param string $code Code parameter from Facebook login - */ - public function verifyFacebook($clientId, $clientSecret, $code) - { - $url = $this->baseApiUrl . '/v2.1/facebook/token'; - $params = [ - 'client_id' => $clientId, - 'client_secret' => $clientSecret, - 'code' => $code, - ]; - - 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; - } } diff --git a/app/src/User/UserController.php b/app/src/User/UserController.php index 520e68ed3..7863dcaf6 100644 --- a/app/src/User/UserController.php +++ b/app/src/User/UserController.php @@ -36,7 +36,6 @@ protected function defineRoutes(\Slim\Slim $app) ->via('GET', 'POST')->name('user-new-password'); $app->get('/user/twitter-login', [$this, 'loginWithTwitter'])->name('twitter-login'); $app->get('/user/twitter-access', [$this, 'accessTokenFromTwitter'])->name('twitter-callback'); - $app->get('/user/facebook-access', [$this, 'accessTokenFromFacebook'])->name('facebook-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'); @@ -836,27 +835,6 @@ public function accessTokenFromTwitter() $this->handleLogin($result); } - /** - * The Facebook callback URL returns here - */ - public function accessTokenFromFacebook() - { - $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 - $code = $request->get('code'); - - $authApi = $this->application->container->get(AuthApi::class); - $result = $authApi->verifyFacebook($clientId, $clientSecret, $code); - - $this->handleLogin($result); - } - /** * Process a user login result. If result is false, then we failed, otherwise * update the session. From c04d7198d98e6a265bf329f715b780c81afdf29c Mon Sep 17 00:00:00 2001 From: Sjors Keuninkx Date: Fri, 29 Mar 2024 08:33:21 +0100 Subject: [PATCH 3/4] Removed twitter login #922 --- app/src/User/AuthApi.php | 27 -------------------------- app/src/User/UserController.php | 28 --------------------------- app/templates/_common/login.html.twig | 4 ---- 3 files changed, 59 deletions(-) diff --git a/app/src/User/AuthApi.php b/app/src/User/AuthApi.php index 24d2b2755..931b5e8f0 100644 --- a/app/src/User/AuthApi.php +++ b/app/src/User/AuthApi.php @@ -35,33 +35,6 @@ public function login($username, $password, $clientId, $clientSecret) return false; } - /** - * Get a request token from the API from Twitter - * - * @param string $clientId OAuth client ID - * @param string $clientSecret OAuth client secret - * @return string|false The token - */ - public function getTwitterRequestToken($clientId, $clientSecret) - { - $url = $this->baseApiUrl . '/v2.1/twitter/request_token'; - $params = [ - 'client_id' => $clientId, - 'client_secret' => $clientSecret, - ]; - - list($status, $result, $headers) = $this->apiPost($url, $params); - if ($status == 201) { - // we got one, data is actually in the body - $data = json_decode($result); - if ($data) { - $token = $data->twitter_request_tokens[0]; - return $token->token; - } - } - return false; - } - /** * Send Twitter verification token to the API to log us in * diff --git a/app/src/User/UserController.php b/app/src/User/UserController.php index 7863dcaf6..2339cad9c 100644 --- a/app/src/User/UserController.php +++ b/app/src/User/UserController.php @@ -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-login', [$this, 'loginWithTwitter'])->name('twitter-login'); $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'); @@ -786,33 +785,6 @@ public function newPassword() ); } - /** - * This gets a request token via the API, and forwards the user - * to Twitter to log in and grant us access - */ - public function loginWithTwitter() - { - // ask the API for a request token - $config = $this->application->config('oauth'); - $clientId = $config['client_id']; - $clientSecret = $config['client_secret']; - - $authApi = $this->application->container->get(AuthApi::class); - $request_token = $authApi->getTwitterRequestToken($clientId, $clientSecret); - - if ($request_token) { - // forward the user - header("Location: https://api.twitter.com/oauth/authenticate?oauth_token=" . $request_token); - exit; - } - - $this->application->flash( - 'error', - 'We could not log you in with twitter' - ); - $this->application->redirect('/'); - } - /** * The callback URL should point to here */ diff --git a/app/templates/_common/login.html.twig b/app/templates/_common/login.html.twig index 623c10d1b..6ac52a9f0 100644 --- a/app/templates/_common/login.html.twig +++ b/app/templates/_common/login.html.twig @@ -17,10 +17,6 @@ or register now -
Problems logging in?
Resend welcome email
From ce0754be5bf1e823fcfbf335cb91b6f6db4f7ecf Mon Sep 17 00:00:00 2001 From: Sjors Keuninkx Date: Fri, 29 Mar 2024 08:34:05 +0100 Subject: [PATCH 4/4] Removed functionality for retrieving twitter access token #922 --- app/src/User/AuthApi.php | 28 ---------------------------- app/src/User/UserController.php | 23 ----------------------- 2 files changed, 51 deletions(-) diff --git a/app/src/User/AuthApi.php b/app/src/User/AuthApi.php index 931b5e8f0..4b3d9cc1e 100644 --- a/app/src/User/AuthApi.php +++ b/app/src/User/AuthApi.php @@ -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; - } } diff --git a/app/src/User/UserController.php b/app/src/User/UserController.php index 2339cad9c..8dd87eb63 100644 --- a/app/src/User/UserController.php +++ b/app/src/User/UserController.php @@ -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'); @@ -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.