summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-01-04 22:42:24 +0100
committerGitHub <noreply@github.com>2019-01-04 22:42:24 +0100
commit076f6b8ed1791a5777da36560804c8758adc208f (patch)
treefe68d5e3bcd7c359667e017525573192e9f7f71e
parent40e3a7bbcfd05f7d2777392d6b28a5ba09b6d072 (diff)
parente6ac2339476ad97a40664364ac43e3a08fa3acc9 (diff)
downloadnextcloud-server-076f6b8ed1791a5777da36560804c8758adc208f.tar.gz
nextcloud-server-076f6b8ed1791a5777da36560804c8758adc208f.zip
Merge pull request #13363 from nextcloud/fix/loginflow_apptoken_ios
Fix loginflow with apptoken enter on iOS
-rw-r--r--core/Controller/ClientFlowLoginController.php12
-rw-r--r--core/js/login/authpicker.js8
-rw-r--r--core/routes.php1
-rw-r--r--core/templates/loginflow/authpicker.php7
4 files changed, 17 insertions, 11 deletions
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php
index 7fb89f5ff82..c00a720ac57 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 2d4bcc33158..e1e34bbd8d6 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 c33fc6487f2..f00e75cec89 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 7c7eabd308c..890e0b186d9 100644
--- a/core/templates/loginflow/authpicker.php
+++ b/core/templates/loginflow/authpicker.php
@@ -44,7 +44,7 @@ $urlGenerator = $_['urlGenerator'];
</a>
</p>
- <fieldset id="app-token-login-field" class="hidden">
+ <form action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.apptokenRedirect')); ?>" method="post" id="app-token-login-field" class="hidden">
<p class="grouptop">
<input type="text" name="user" id="user" placeholder="<?php p($l->t('Username')) ?>">
<label for="user" class="infield"><?php p($l->t('Username')) ?></label>
@@ -53,9 +53,10 @@ $urlGenerator = $_['urlGenerator'];
<input type="password" name="password" id="password" placeholder="<?php p($l->t('App token')) ?>">
<label for="password" class="infield"><?php p($l->t('Password')) ?></label>
</p>
- <input type="hidden" id="serverHost" value="<?php p($_['serverHost']) ?>" />
+ <input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
+ <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
<input id="submit-app-token-login" type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Grant access')) ?>">
- </fieldset>
+ </form>
</div>
<?php if(empty($_['oauthState'])): ?>