Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-11-09 00:29:34 +01:00
parent 989a8a3668
commit c2cd5fc5d3
2 changed files with 28 additions and 3 deletions

View file

@ -307,7 +307,16 @@ class ClientFlowLoginController extends Controller {
); );
$this->session->remove('oauth.state'); $this->session->remove('oauth.state');
} else { } 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); return new Http\RedirectResponse($redirectUri);

View file

@ -158,6 +158,10 @@ class ClientFlowLoginControllerTest extends TestCase {
->expects($this->once()) ->expects($this->once())
->method('getName') ->method('getName')
->willReturn('ExampleCloud'); ->willReturn('ExampleCloud');
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('http');
$this->request $this->request
->expects($this->once()) ->expects($this->once())
->method('getServerHost') ->method('getServerHost')
@ -214,6 +218,10 @@ class ClientFlowLoginControllerTest extends TestCase {
->expects($this->once()) ->expects($this->once())
->method('getName') ->method('getName')
->willReturn('ExampleCloud'); ->willReturn('ExampleCloud');
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('http');
$this->request $this->request
->expects($this->once()) ->expects($this->once())
->method('getServerHost') ->method('getServerHost')
@ -423,12 +431,16 @@ class ClientFlowLoginControllerTest extends TestCase {
IToken::PERMANENT_TOKEN, IToken::PERMANENT_TOKEN,
IToken::DO_NOT_REMEMBER IToken::DO_NOT_REMEMBER
); );
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('http');
$this->request $this->request
->expects($this->once()) ->expects($this->once())
->method('getServerHost') ->method('getServerHost')
->willReturn('example.com'); ->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')); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
} }
@ -571,12 +583,16 @@ class ClientFlowLoginControllerTest extends TestCase {
IToken::PERMANENT_TOKEN, IToken::PERMANENT_TOKEN,
IToken::DO_NOT_REMEMBER IToken::DO_NOT_REMEMBER
); );
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('http');
$this->request $this->request
->expects($this->once()) ->expects($this->once())
->method('getServerHost') ->method('getServerHost')
->willReturn('example.com'); ->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')); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
} }
} }