summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-12-08 16:01:57 +0100
committerGitHub <noreply@github.com>2017-12-08 16:01:57 +0100
commit6aac1ffa33a0e1c9acad5eb78854c92dc0e1178a (patch)
treedf6664e70b1bea0a0183d4c5955be4c11ab96e8a
parent4c19e75f5d7bc53f15d10a58b098313ca656f7ce (diff)
parent555fe7047f3140bcc5a46a961a160f59d25662d2 (diff)
downloadnextcloud-server-6aac1ffa33a0e1c9acad5eb78854c92dc0e1178a.tar.gz
nextcloud-server-6aac1ffa33a0e1c9acad5eb78854c92dc0e1178a.zip
Merge pull request #7115 from nextcloud/fix-flow
Fix flow
-rw-r--r--core/Controller/ClientFlowLoginController.php11
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php12
2 files changed, 20 insertions, 3 deletions
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php
index 81ba8009b24..47bbbce640e 100644
--- a/core/Controller/ClientFlowLoginController.php
+++ b/core/Controller/ClientFlowLoginController.php
@@ -307,7 +307,16 @@ class ClientFlowLoginController extends Controller {
);
$this->session->remove('oauth.state');
} else {
- $redirectUri = 'nc://login/server:' . $this->request->getServerHost() . '&user:' . urlencode($loginName) . '&password:' . urlencode($token);
+ $serverPostfix = '';
+
+ if (strpos($this->request->getRequestUri(), '/index.php') !== false) {
+ $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php'));
+ } else if (strpos($this->request->getRequestUri(), '/login/flow') !== false) {
+ $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/flow'));
+ }
+
+ $serverPath = $this->request->getServerProtocol() . "://" . $this->request->getServerHost() . $serverPostfix;
+ $redirectUri = 'nc://login/server:' . $serverPath . '&user:' . urlencode($loginName) . '&password:' . urlencode($token);
}
return new Http\RedirectResponse($redirectUri);
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index 99388e2c441..21673863223 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -425,10 +425,14 @@ class ClientFlowLoginControllerTest extends TestCase {
);
$this->request
->expects($this->once())
+ ->method('getServerProtocol')
+ ->willReturn('http');
+ $this->request
+ ->expects($this->once())
->method('getServerHost')
->willReturn('example.com');
- $expected = new Http\RedirectResponse('nc://login/server:example.com&user:MyLoginName&password:MyGeneratedToken');
+ $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
}
@@ -573,10 +577,14 @@ class ClientFlowLoginControllerTest extends TestCase {
);
$this->request
->expects($this->once())
+ ->method('getServerProtocol')
+ ->willReturn('http');
+ $this->request
+ ->expects($this->once())
->method('getServerHost')
->willReturn('example.com');
- $expected = new Http\RedirectResponse('nc://login/server:example.com&user:MyLoginName&password:MyGeneratedToken');
+ $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
}
}