Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Show user account on grant loginflow step
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 13, 2022
commit db1813f640949687b783fb1097fec2c0d9b7387f
6 changes: 6 additions & 0 deletions core/Controller/ClientFlowLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
Expand Down Expand Up @@ -251,10 +252,15 @@ public function grantPage(string $stateToken = '',
$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(),
Expand Down
11 changes: 11 additions & 0 deletions core/Controller/ClientFlowLoginV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Security\ISecureRandom;

class ClientFlowLoginV2Controller extends Controller {
Expand All @@ -54,6 +56,8 @@ class ClientFlowLoginV2Controller extends Controller {
private $urlGenerator;
/** @var ISession */
private $session;
/** @var IUserSession */
private $userSession;
/** @var ISecureRandom */
private $random;
/** @var Defaults */
Expand All @@ -68,6 +72,7 @@ public function __construct(string $appName,
LoginFlowV2Service $loginFlowV2Service,
IURLGenerator $urlGenerator,
ISession $session,
IUserSession $userSession,
ISecureRandom $random,
Defaults $defaults,
?string $userId,
Expand All @@ -76,6 +81,7 @@ public function __construct(string $appName,
$this->loginFlowV2Service = $loginFlowV2Service;
$this->urlGenerator = $urlGenerator;
$this->session = $session;
$this->userSession = $userSession;
$this->random = $random;
$this->defaults = $defaults;
$this->userId = $userId;
Expand Down Expand Up @@ -162,10 +168,15 @@ public function grantPage(string $stateToken): StandaloneTemplateResponse {
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,
Expand Down
8 changes: 7 additions & 1 deletion core/templates/loginflow/grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

<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>',
Expand All @@ -44,7 +50,7 @@
<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">
Expand Down
10 changes: 8 additions & 2 deletions core/templates/loginflowv2/grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

<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>',
Expand All @@ -41,10 +47,10 @@
<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>