diff --git a/app/src/User/AuthApi.php b/app/src/User/AuthApi.php index ee9a41dc6..4b3d9cc1e 100644 --- a/app/src/User/AuthApi.php +++ b/app/src/User/AuthApi.php @@ -34,87 +34,4 @@ 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 - * - * @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; - } - - /** - * 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..8dd87eb63 100644 --- a/app/src/User/UserController.php +++ b/app/src/User/UserController.php @@ -34,9 +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/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'); @@ -787,76 +784,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 - */ - 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); - } - - /** - * 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. 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..6ac52a9f0 100644 --- a/app/templates/_common/login.html.twig +++ b/app/templates/_common/login.html.twig @@ -17,11 +17,6 @@ or register now -
-
Already registered?
- Sign in with Twitter - Log In with Facebook -
Problems logging in?
Resend welcome email
@@ -29,4 +24,4 @@ Forgotten username
- + \ No newline at end of file