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
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-03-22 15:54:36 +0300
committerGitHub <noreply@github.com>2022-03-22 15:54:36 +0300
commit75158f39851c7703b993f261db873d9eb9613153 (patch)
tree8f26a10b3d32773710bd8fa37a192d6b7c7aebb8 /core
parent3c649bc3c0a63f02bc0efbab3d1846dd5a495fcb (diff)
parente935c30e7da298f6594849c19c9345faf0b96796 (diff)
Merge pull request #31535 from nextcloud/backport/31519/stable22
[stable22] Fix occ user:add-app-password
Diffstat (limited to 'core')
-rw-r--r--core/Command/User/AddAppPassword.php20
-rw-r--r--core/register_command.php2
2 files changed, 13 insertions, 9 deletions
diff --git a/core/Command/User/AddAppPassword.php b/core/Command/User/AddAppPassword.php
index a29692df045..7a2270e20b1 100644
--- a/core/Command/User/AddAppPassword.php
+++ b/core/Command/User/AddAppPassword.php
@@ -23,10 +23,11 @@
*/
namespace OC\Core\Command\User;
+use OC\Authentication\Events\AppPasswordCreatedEvent;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
-use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
@@ -44,17 +45,17 @@ class AddAppPassword extends Command {
protected $tokenProvider;
/** @var ISecureRandom */
private $random;
- /** @var ICrypto */
- private $crypto;
+ /** @var IEventDispatcher */
+ private $eventDispatcher;
public function __construct(IUserManager $userManager,
IProvider $tokenProvider,
ISecureRandom $random,
- ICrypto $crypto) {
+ IEventDispatcher $eventDispatcher) {
$this->tokenProvider = $tokenProvider;
$this->userManager = $userManager;
$this->random = $random;
- $this->crypto = $crypto;
+ $this->eventDispatcher = $eventDispatcher;
parent::__construct();
}
@@ -108,11 +109,10 @@ class AddAppPassword extends Command {
return 1;
}
- $output->writeln('<info>The password is not validated so what you provide is what gets recorded in the token</info>');
-
+ $output->writeln('<comment>The password has not been validated, some features might not work as intended.</comment>');
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
- $this->tokenProvider->generateToken(
+ $generatedToken = $this->tokenProvider->generateToken(
$token,
$user->getUID(),
$user->getUID(),
@@ -122,6 +122,10 @@ class AddAppPassword extends Command {
IToken::DO_NOT_REMEMBER
);
+ $this->eventDispatcher->dispatchTyped(
+ new AppPasswordCreatedEvent($generatedToken)
+ );
+
$output->writeln('app password:');
$output->writeln($token);
diff --git a/core/register_command.php b/core/register_command.php
index 526707b004d..5ec12ee1b8b 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -186,7 +186,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
- $application->add(new OC\Core\Command\User\AddAppPassword(\OC::$server->get(\OCP\IUserManager::class), \OC::$server->get(\OC\Authentication\Token\IProvider::class), \OC::$server->get(\OCP\Security\ISecureRandom::class), \OC::$server->get(\OCP\Security\ICrypto::class)));
+ $application->add(new OC\Core\Command\User\AddAppPassword(\OC::$server->get(\OCP\IUserManager::class), \OC::$server->get(\OC\Authentication\Token\IProvider::class), \OC::$server->get(\OCP\Security\ISecureRandom::class), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class)));
$application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager()));