Fix flow
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
989a8a3668
commit
c2cd5fc5d3
2 changed files with 28 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -158,6 +158,10 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('getName')
|
||||
->willReturn('ExampleCloud');
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getServerProtocol')
|
||||
->willReturn('http');
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getServerHost')
|
||||
|
@ -214,6 +218,10 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('getName')
|
||||
->willReturn('ExampleCloud');
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getServerProtocol')
|
||||
->willReturn('http');
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getServerHost')
|
||||
|
@ -423,12 +431,16 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
IToken::PERMANENT_TOKEN,
|
||||
IToken::DO_NOT_REMEMBER
|
||||
);
|
||||
$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'));
|
||||
}
|
||||
|
||||
|
@ -571,12 +583,16 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
IToken::PERMANENT_TOKEN,
|
||||
IToken::DO_NOT_REMEMBER
|
||||
);
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue