diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 23bd42a0f1..ab9d98df8d 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -204,6 +204,44 @@ class ClientFlowLoginController extends Controller { ); } + /** + * @NoAdminRequired + * @NoCSRFRequired + * @UseSession + * + * @param string $stateToken + * @param string $clientIdentifier + * @return TemplateResponse + */ + public function grantPage($stateToken = '', + $clientIdentifier = '') { + if(!$this->isValidToken($stateToken)) { + return $this->stateTokenForbiddenResponse(); + } + + $clientName = $this->getClientName(); + $client = null; + if($clientIdentifier !== '') { + $client = $this->clientMapper->getByIdentifier($clientIdentifier); + $clientName = $client->getName(); + } + + return new TemplateResponse( + $this->appName, + 'loginflow/grant', + [ + 'client' => $clientName, + 'clientIdentifier' => $clientIdentifier, + 'instanceName' => $this->defaults->getName(), + 'urlGenerator' => $this->urlGenerator, + 'stateToken' => $stateToken, + 'serverHost' => $this->request->getServerHost(), + 'oauthState' => $this->session->get('oauth.state'), + ], + 'guest' + ); + } + /** * @NoAdminRequired * @NoCSRFRequired diff --git a/core/routes.php b/core/routes.php index 1c7be78bc7..cc1bd34d89 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#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' => '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 1858f8bcb6..4e2282a180 100644 --- a/core/templates/loginflow/authpicker.php +++ b/core/templates/loginflow/authpicker.php @@ -28,9 +28,9 @@ $urlGenerator = $_['urlGenerator']; ?>
- t('You are about to grant %s access to your %s account.', [
+ t('Please log in before granting %s access to your %s account.', [
'' . \OCP\Util::sanitizeHTML($_['client']) . '',
\OCP\Util::sanitizeHTML($_['instanceName'])
])) ?>
@@ -39,8 +39,8 @@ $urlGenerator = $_['urlGenerator'];
+ t('You are about to grant %s access to your %s account.', [ + '' . \OCP\Util::sanitizeHTML($_['client']) . '', + \OCP\Util::sanitizeHTML($_['instanceName']) + ])) ?> +
+ ++ + + +
+