From e6ac2339476ad97a40664364ac43e3a08fa3acc9 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 4 Jan 2019 20:30:37 +0100 Subject: [PATCH] Fix loginflow with apptoken enter on iOS It seems iOS doesn't like us to change the location. So now we submit it to the server that geneartes the redirect. Signed-off-by: Roeland Jago Douma --- core/Controller/ClientFlowLoginController.php | 12 ++++++++++++ core/js/login/authpicker.js | 8 -------- core/routes.php | 1 + core/templates/loginflow/authpicker.php | 7 ++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 7fb89f5ff8..c00a720ac5 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -327,6 +327,18 @@ class ClientFlowLoginController extends Controller { return new Http\RedirectResponse($redirectUri); } + /** + * @PublicPage + */ + public function apptokenRedirect(string $stateToken, string $user, string $password) { + if (!$this->isValidToken($stateToken)) { + return $this->stateTokenForbiddenResponse(); + } + + $redirectUri = 'nc://login/server:' . $this->getServerPath() . '&user:' . urlencode($user) . '&password:' . urlencode($password); + return new Http\RedirectResponse($redirectUri); + } + private function getServerPath(): string { $serverPostfix = ''; diff --git a/core/js/login/authpicker.js b/core/js/login/authpicker.js index 2d4bcc3315..e1e34bbd8d 100644 --- a/core/js/login/authpicker.js +++ b/core/js/login/authpicker.js @@ -5,12 +5,4 @@ jQuery(document).ready(function() { $('#redirect-link').addClass('hidden'); $('#app-token-login-field').removeClass('hidden'); }); - - $('#submit-app-token-login').click(function(e) { - e.preventDefault(); - window.location.href = 'nc://login/server:' - + encodeURIComponent($('#serverHost').val()) - + "&user:" + encodeURIComponent($('#user').val()) - + "&password:" + encodeURIComponent($('#password').val()); - }); }); diff --git a/core/routes.php b/core/routes.php index c33fc6487f..f00e75cec8 100644 --- a/core/routes.php +++ b/core/routes.php @@ -54,6 +54,7 @@ $application->registerRoutes($this, [ ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], + ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'], ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], diff --git a/core/templates/loginflow/authpicker.php b/core/templates/loginflow/authpicker.php index 7c7eabd308..890e0b186d 100644 --- a/core/templates/loginflow/authpicker.php +++ b/core/templates/loginflow/authpicker.php @@ -44,7 +44,7 @@ $urlGenerator = $_['urlGenerator'];

- +