From db1813f640949687b783fb1097fec2c0d9b7387f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 13 May 2022 10:50:30 +0200 Subject: [PATCH] Show user account on grant loginflow step Signed-off-by: Joas Schilling --- core/Controller/ClientFlowLoginController.php | 6 ++++++ core/Controller/ClientFlowLoginV2Controller.php | 11 +++++++++++ core/templates/loginflow/grant.php | 8 +++++++- core/templates/loginflowv2/grant.php | 10 ++++++++-- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index ad8bc8eb086..d24a49ee376 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; @@ -251,10 +252,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 ab46cb4b729..27585cbdb7e 100644 --- a/core/Controller/ClientFlowLoginV2Controller.php +++ b/core/Controller/ClientFlowLoginV2Controller.php @@ -42,6 +42,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 { @@ -54,6 +56,8 @@ class ClientFlowLoginV2Controller extends Controller { private $urlGenerator; /** @var ISession */ private $session; + /** @var IUserSession */ + private $userSession; /** @var ISecureRandom */ private $random; /** @var Defaults */ @@ -68,6 +72,7 @@ class ClientFlowLoginV2Controller extends Controller { LoginFlowV2Service $loginFlowV2Service, IURLGenerator $urlGenerator, ISession $session, + IUserSession $userSession, ISecureRandom $random, Defaults $defaults, ?string $userId, @@ -76,6 +81,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; @@ -162,10 +168,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 @@ -29,6 +29,12 @@ $urlGenerator = $_['urlGenerator'];

t('Account access')) ?>

+

+ t('Currently logged in as %1$s (%2$s).', [ + $_['userDisplayName'], + $_['userId'], + ])) ?> +

t('You are about to grant %1$s access to your %2$s account.', [ '' . \OCP\Util::sanitizeHTML($_['client']) . '', @@ -44,7 +50,7 @@ $urlGenerator = $_['urlGenerator']; - +

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 @@ -29,6 +29,12 @@ $urlGenerator = $_['urlGenerator'];

t('Account access')) ?>

+

+ t('Currently logged in as %1$s (%2$s).', [ + $_['userDisplayName'], + $_['userId'], + ])) ?> +

t('You are about to grant %1$s access to your %2$s account.', [ '' . \OCP\Util::sanitizeHTML($_['client']) . '', @@ -41,10 +47,10 @@ $urlGenerator = $_['urlGenerator'];

- +
-
+

-- 2.39.5