]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/OAuth/Authorize.php
API: Show different ids on reshares / don't check for client secret
[friendica.git] / src / Module / OAuth / Authorize.php
index d39cbe353d0299b1e65c3c3081db2aa587f0ff30..efa0666940e77aa3adba5779b849ef67eee68998 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -37,9 +37,9 @@ class Authorize extends BaseApi
        /**
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function rawContent()
+       protected function rawContent(array $request = [])
        {
-               $request = self::getRequest([
+               $request = $this->getRequest([
                        'force_login'   => '', // Forces the user to re-login, which is necessary for authorizing with multiple accounts from the same instance.
                        'response_type' => '', // Should be set equal to "code".
                        'client_id'     => '', // Client ID, obtained during app registration.
@@ -47,7 +47,7 @@ class Authorize extends BaseApi
                        'redirect_uri'  => '', // Set a URI to redirect the user to. If this parameter is set to "urn:ietf:wg:oauth:2.0:oob" then the authorization code will be shown instead. Must match one of the redirect URIs declared during app registration.
                        'scope'         => 'read', // List of requested OAuth scopes, separated by spaces (or by pluses, if using query parameters). Must be a subset of scopes declared during app registration. If not provided, defaults to "read".
                        'state'         => '',
-               ]);
+               ], $request);
 
                if ($request['response_type'] != 'code') {
                        Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);
@@ -70,7 +70,7 @@ class Authorize extends BaseApi
                unset($redirect_request['pagename']);
                $redirect = 'oauth/authorize?' . http_build_query($redirect_request);
 
-               $uid = local_user();
+               $uid = DI::userSession()->getLocalUserId();
                if (empty($uid)) {
                        Logger::info('Redirect to login');
                        DI::app()->redirect('login?return_path=' . urlencode($redirect));
@@ -97,7 +97,7 @@ class Authorize extends BaseApi
                self::$oauth_code = $token['code'];
        }
 
-       public function content(): string
+       protected function content(array $request = []): string
        {
                if (empty(self::$oauth_code)) {
                        return '';