Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-05-13 11:50:30 +0300
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2022-05-16 13:17:11 +0300
commit7cee0eb8c1a78acd92ed48f5b5c91e6cd6eb7a43 (patch)
treeb7d229af6ca9d0f1c2369f945fb344f5e1257617
parent032e64f730e46877b4bfa209c63cffd524bb4eaf (diff)
Show user account on grant loginflow step
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--core/Controller/ClientFlowLoginController.php6
-rw-r--r--core/Controller/ClientFlowLoginV2Controller.php11
-rw-r--r--core/templates/loginflow/grant.php8
-rw-r--r--core/templates/loginflowv2/grant.php10
4 files changed, 32 insertions, 3 deletions
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php
index d67a065a14e..6a88705c6e4 100644
--- a/core/Controller/ClientFlowLoginController.php
+++ b/core/Controller/ClientFlowLoginController.php
@@ -49,6 +49,7 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
+use OCP\IUser;
use OCP\IUserSession;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
@@ -250,10 +251,15 @@ class ClientFlowLoginController extends Controller {
$csp->addAllowedFormActionDomain('nc://*');
}
+ /** @var IUser $user */
+ $user = $this->userSession->getUser();
+
$response = new StandaloneTemplateResponse(
$this->appName,
'loginflow/grant',
[
+ 'userId' => $user->getUID(),
+ 'userDisplayName' => $user->getDisplayName(),
'client' => $clientName,
'clientIdentifier' => $clientIdentifier,
'instanceName' => $this->defaults->getName(),
diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php
index 205c1ff8a1c..f2b9399301f 100644
--- a/core/Controller/ClientFlowLoginV2Controller.php
+++ b/core/Controller/ClientFlowLoginV2Controller.php
@@ -41,6 +41,8 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserSession;
use OCP\Security\ISecureRandom;
class ClientFlowLoginV2Controller extends Controller {
@@ -53,6 +55,8 @@ class ClientFlowLoginV2Controller extends Controller {
private $urlGenerator;
/** @var ISession */
private $session;
+ /** @var IUserSession */
+ private $userSession;
/** @var ISecureRandom */
private $random;
/** @var Defaults */
@@ -67,6 +71,7 @@ class ClientFlowLoginV2Controller extends Controller {
LoginFlowV2Service $loginFlowV2Service,
IURLGenerator $urlGenerator,
ISession $session,
+ IUserSession $userSession,
ISecureRandom $random,
Defaults $defaults,
?string $userId,
@@ -75,6 +80,7 @@ class ClientFlowLoginV2Controller extends Controller {
$this->loginFlowV2Service = $loginFlowV2Service;
$this->urlGenerator = $urlGenerator;
$this->session = $session;
+ $this->userSession = $userSession;
$this->random = $random;
$this->defaults = $defaults;
$this->userId = $userId;
@@ -160,10 +166,15 @@ class ClientFlowLoginV2Controller extends Controller {
return $this->loginTokenForbiddenResponse();
}
+ /** @var IUser $user */
+ $user = $this->userSession->getUser();
+
return new StandaloneTemplateResponse(
$this->appName,
'loginflowv2/grant',
[
+ 'userId' => $user->getUID(),
+ 'userDisplayName' => $user->getDisplayName(),
'client' => $flow->getClientName(),
'instanceName' => $this->defaults->getName(),
'urlGenerator' => $this->urlGenerator,
diff --git a/core/templates/loginflow/grant.php b/core/templates/loginflow/grant.php
index c537c47ea64..04fdced1c62 100644
--- a/core/templates/loginflow/grant.php
+++ b/core/templates/loginflow/grant.php
@@ -30,6 +30,12 @@ $urlGenerator = $_['urlGenerator'];
<div class="picker-window">
<h2><?php p($l->t('Account access')) ?></h2>
<p class="info">
+ <?php p($l->t('Currently logged in as %1$s (%2$s).', [
+ $_['userDisplayName'],
+ $_['userId'],
+ ])) ?>
+ </p>
+ <p class="info">
<?php print_unescaped($l->t('You are about to grant %1$s access to your %2$s account.', [
'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
\OCP\Util::sanitizeHTML($_['instanceName'])
@@ -44,7 +50,7 @@ $urlGenerator = $_['urlGenerator'];
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<input type="hidden" name="oauthState" value="<?php p($_['oauthState']) ?>" />
- <?php if (p($_['direct'])) { ?>
+ <?php if ($_['direct']) { ?>
<input type="hidden" name="direct" value="1" />
<?php } ?>
<div id="submit-wrapper">
diff --git a/core/templates/loginflowv2/grant.php b/core/templates/loginflowv2/grant.php
index b036d33ad7c..19005a20e2c 100644
--- a/core/templates/loginflowv2/grant.php
+++ b/core/templates/loginflowv2/grant.php
@@ -30,6 +30,12 @@ $urlGenerator = $_['urlGenerator'];
<div class="picker-window">
<h2><?php p($l->t('Account access')) ?></h2>
<p class="info">
+ <?php p($l->t('Currently logged in as %1$s (%2$s).', [
+ $_['userDisplayName'],
+ $_['userId'],
+ ])) ?>
+ </p>
+ <p class="info">
<?php print_unescaped($l->t('You are about to grant %1$s access to your %2$s account.', [
'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
\OCP\Util::sanitizeHTML($_['instanceName'])
@@ -41,10 +47,10 @@ $urlGenerator = $_['urlGenerator'];
<p id="redirect-link">
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.generateAppPassword')) ?>">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
- <input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
+ <input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<div id="submit-wrapper">
<input type="submit" class="login primary icon-confirm-white" title="" value="<?php p($l->t('Grant access')); ?>" />
- </div>
+ </div>
</form>
</p>
</div>