Merge pull request #2 from nextcloud/override-in-app
Override Request object in app.php
This commit is contained in:
Коммит
f2faefd908
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ source_dir=$(build_dir)/source
|
|||
sign_dir=$(build_dir)/sign
|
||||
package_name=$(app_name)
|
||||
cert_dir=$(HOME)/.nextcloud/certificates
|
||||
version+=1.0.5
|
||||
version+=1.0.6
|
||||
|
||||
all: appstore
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ class FeatureContext implements Context {
|
|||
private function sendRequest($username,
|
||||
$password,
|
||||
$cookies = false) {
|
||||
|
||||
$params = [];
|
||||
if($cookies) {
|
||||
$params['cookies'] = \GuzzleHttp\Cookie\CookieJar::fromArray([
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$serverContainer = \OC::$server;
|
||||
|
||||
$currentUrl = $serverContainer->getRequest()->getServerProtocol() . '://' .$serverContainer->getRequest()->getServerHost() . $serverContainer->getRequest()->getRequestUri();
|
||||
$expectedUrl = $serverContainer->getURLGenerator()->getAbsoluteURL('/index.php/apps/loginviapost/login');
|
||||
|
||||
// Only process on login URL
|
||||
if($currentUrl !== $expectedUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register the request service again
|
||||
$serverContainer->registerService(\OCP\IRequest::class, function() use ($serverContainer) {
|
||||
if (isset($serverContainer['urlParams'])) {
|
||||
$urlParams = $this['urlParams'];
|
||||
} else {
|
||||
$urlParams = [];
|
||||
}
|
||||
|
||||
if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
|
||||
&& in_array('fakeinput', stream_get_wrappers())
|
||||
) {
|
||||
$stream = 'fakeinput://data';
|
||||
} else {
|
||||
$stream = 'php://input';
|
||||
}
|
||||
|
||||
return new \OCA\LoginViaPost\Request(
|
||||
[
|
||||
'get' => $_GET,
|
||||
'post' => $_POST,
|
||||
'files' => $_FILES,
|
||||
'server' => $_SERVER,
|
||||
'env' => $_ENV,
|
||||
'cookies' => $_COOKIE,
|
||||
'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
|
||||
? $_SERVER['REQUEST_METHOD']
|
||||
: null,
|
||||
'urlParams' => $urlParams,
|
||||
],
|
||||
$serverContainer->getSecureRandom(),
|
||||
$serverContainer->getConfig(),
|
||||
$serverContainer->getCsrfTokenManager(),
|
||||
$stream
|
||||
);
|
||||
});
|
|
@ -22,7 +22,7 @@ the following form explains the usage of this plugin:
|
|||
</body>
|
||||
</html>
|
||||
```]]></description>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.6</version>
|
||||
<licence>agpl</licence>
|
||||
<author>Lukas Reschke</author>
|
||||
<namespace>LoginViaPost</namespace>
|
||||
|
@ -32,4 +32,7 @@ the following form explains the usage of this plugin:
|
|||
<dependencies>
|
||||
<nextcloud min-version="12" max-version="13"/>
|
||||
</dependencies>
|
||||
<types>
|
||||
<session/>
|
||||
</types>
|
||||
</info>
|
||||
|
|
Загрузка…
Ссылка в новой задаче