From 87d6ea0eb396ca0dbaca2e32d897ccd36059f84c Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 4 Mar 2020 10:58:43 +0300 Subject: [PATCH] fix wording --- .../Command/User/UserPasswordCommand.php | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php b/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php index bd87c4d885..94e400aa14 100644 --- a/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php +++ b/lib/Alchemy/Phrasea/Command/User/UserPasswordCommand.php @@ -39,7 +39,7 @@ class UserPasswordCommand extends Command ->addOption('send_renewal_email', null, InputOption::VALUE_NONE, 'Send email link to user for password renewing, work only if --password or --generate are not define') ->addOption('password_hash', null, InputOption::VALUE_OPTIONAL, 'Define a password hashed, work only with password_nonce') ->addOption('password_nonce', null, InputOption::VALUE_OPTIONAL, 'Define a password nonce, work only with password_hash') - ->addOption('get_hash', null, InputOption::VALUE_NONE, 'Return the password hashed and nonce') + ->addOption('dump', null, InputOption::VALUE_NONE, 'Return the password hashed and nonce') ->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format') ->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions') @@ -58,7 +58,7 @@ class UserPasswordCommand extends Command $password = $input->getOption('password'); $generate = $input->getOption('generate'); $sendRenewalEmail = $input->getOption('send_renewal_email'); - $getHash = $input->getOption('get_hash'); + $dump = $input->getOption('dump'); $passwordHash = $input->getOption('password_hash'); $passwordNonce = $input->getOption('password_nonce'); $jsonformat = $input->getOption('jsonformat'); @@ -80,7 +80,7 @@ class UserPasswordCommand extends Command return 0; } - if ($getHash) { + if ($dump) { $oldHash = $user->getPassword(); $oldNonce = $user->getNonce(); } @@ -96,7 +96,7 @@ class UserPasswordCommand extends Command $output->writeln('email link sended for password renewing!'); return 0; - } elseif (!$password && !$sendRenewalEmail && ! $getHash) { + } elseif (!$password && !$sendRenewalEmail && ! $dump) { $output->writeln('choose one option to set a password!'); return 0; @@ -121,25 +121,34 @@ class UserPasswordCommand extends Command $userManipulator->setPassword($user,$password); } - if (($password || $generate || $getHash) && $oldHash) { + if ($dump) { if ($jsonformat) { - if ($password) { - $hash['new_password'] = $password; - } $hash['password_hash'] = $oldHash; $hash['nonce'] = $oldNonce; echo json_encode($hash); + + return 0; } else { - if ($password) { - $output->writeln('new_password :' . $password); - } $output->writeln('password_hash :' . $oldHash); $output->writeln('nonce :' . $oldNonce); + + return 0; + } + } + + if (($password || $generate)) { + if ($jsonformat) { + $hash['new_password'] = $password; + $hash['previous_password_hash'] = $oldHash; + $hash['previous_nonce'] = $oldNonce; + + echo json_encode($hash); + } else { + $output->writeln('new_password :' . $password); + $output->writeln('previous_password_hash :' . $oldHash); + $output->writeln('previous_nonce :' . $oldNonce); } - - } elseif (is_null($password)) { - $output->writeln('password undefined'); } return 0;