Skip to content

Commit

Permalink
Merge pull request #13371 from nextcloud/backport/13363/stable14
Browse files Browse the repository at this point in the history
[stable14] Fix loginflow with apptoken enter on iOS
  • Loading branch information
MorrisJobke committed Jan 4, 2019
2 parents 7a0772e + 5cf1a3d commit 11994b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
12 changes: 12 additions & 0 deletions core/Controller/ClientFlowLoginController.php
Expand Up @@ -355,6 +355,18 @@ public function generateAppPassword($stateToken,
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 = '';

Expand Down
8 changes: 0 additions & 8 deletions core/js/login/authpicker.js
Expand Up @@ -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());
});
});
1 change: 1 addition & 0 deletions core/routes.php
Expand Up @@ -55,6 +55,7 @@
['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', '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'],
Expand Down
7 changes: 4 additions & 3 deletions core/templates/loginflow/authpicker.php
Expand Up @@ -44,7 +44,7 @@
</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>
Expand All @@ -53,9 +53,10 @@
<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'])): ?>
Expand Down

0 comments on commit 11994b6

Please sign in to comment.