Merge branch 'master' into docker-compose-merge

This commit is contained in:
Nicolas Maillat
2020-03-03 22:39:09 +01:00
committed by GitHub
4 changed files with 10 additions and 60 deletions

View File

@@ -246,6 +246,7 @@ class UserApplicationsCommand extends Command
$account->getUser()->getId(), $account->getUser()->getId(),
$application->getName(), $application->getName(),
$application->getClientId(), $application->getClientId(),
$application->getClientSecret(),
$application->getRedirectUri(), $application->getRedirectUri(),
($token) ? $token->getOauthToken() : '-', ($token) ? $token->getOauthToken() : '-',
$application->isPasswordGranted() ? "true": "false" $application->isPasswordGranted() ? "true": "false"
@@ -253,7 +254,7 @@ class UserApplicationsCommand extends Command
} }
$applicationTable = $this->getHelperSet()->get('table'); $applicationTable = $this->getHelperSet()->get('table');
$headers = ['app_id', 'user_id', 'name', 'client_id', 'callback_url', 'generated token', 'grant_password status']; $headers = ['app_id', 'user_id', 'name', 'client_id', 'client_secret', 'callback_url', 'generated token', 'grant_password status'];
if ($jsonformat ) { if ($jsonformat ) {
foreach ($applicationList as $appList) { foreach ($applicationList as $appList) {
@@ -312,7 +313,7 @@ class UserApplicationsCommand extends Command
$application->isPasswordGranted() ? "true": "false" $application->isPasswordGranted() ? "true": "false"
]; ];
$headers = ['client secret', 'client ID', 'Authorize endpoint url', 'Access endpoint', 'generated token', 'grant_password status']; $headers = ['client_secret', 'client_id', 'Authorize endpoint url', 'Access endpoint', 'generated token', 'grant_password status'];
if ($jsonformat ) { if ($jsonformat ) {
$createdAppInfo = array_combine($headers, $applicationCreated); $createdAppInfo = array_combine($headers, $applicationCreated);
echo json_encode($createdAppInfo); echo json_encode($createdAppInfo);

View File

@@ -30,8 +30,8 @@ class UserListCommand extends Command
{ {
parent::__construct('user:list'); parent::__construct('user:list');
$this->setDescription('List of all user (experimental)') $this->setDescription('List of all user <comment>(experimental)</>')
->addOption('user_id', null, InputOption::VALUE_OPTIONAL, ' The id of user export only info this user ') ->addOption('user_id', null, InputOption::VALUE_OPTIONAL, 'The id of user export only info this user ')
->addOption('user_email', null, InputOption::VALUE_OPTIONAL, 'The mail of user export only info this user .') ->addOption('user_email', null, InputOption::VALUE_OPTIONAL, 'The mail of user export only info this user .')
->addOption('database_id', null, InputOption::VALUE_OPTIONAL, 'Id of database.') ->addOption('database_id', null, InputOption::VALUE_OPTIONAL, 'Id of database.')
->addOption('collection_id', null, InputOption::VALUE_OPTIONAL, 'Id of the collection.') ->addOption('collection_id', null, InputOption::VALUE_OPTIONAL, 'Id of the collection.')
@@ -39,7 +39,6 @@ class UserListCommand extends Command
->addOption('guest', null, InputOption::VALUE_NONE, 'Only guest user') ->addOption('guest', null, InputOption::VALUE_NONE, 'Only guest user')
->addOption('created', null, InputOption::VALUE_OPTIONAL, 'Created at with operator,aaaa-mm-jj hh:mm:ss.') ->addOption('created', null, InputOption::VALUE_OPTIONAL, 'Created at with operator,aaaa-mm-jj hh:mm:ss.')
->addOption('updated', null, InputOption::VALUE_OPTIONAL, 'Update at with operator,aaaa-mm-jj hh:mm:ss.') ->addOption('updated', null, InputOption::VALUE_OPTIONAL, 'Update at with operator,aaaa-mm-jj hh:mm:ss.')
->addOption('application', null, InputOption::VALUE_NONE, 'List application of user work only if --user_id is set')
->addOption('right', null, InputOption::VALUE_NONE, 'Show right information') ->addOption('right', null, InputOption::VALUE_NONE, 'Show right information')
->addOption('adress', null, InputOption::VALUE_NONE, 'Show adress information') ->addOption('adress', null, InputOption::VALUE_NONE, 'Show adress information')
->addOption('models', null, InputOption::VALUE_NONE, "Show only defined models, if --user_id is set with --models it's the template owner") ->addOption('models', null, InputOption::VALUE_NONE, "Show only defined models, if --user_id is set with --models it's the template owner")
@@ -58,7 +57,6 @@ class UserListCommand extends Command
$collectionId = $input->getOption('collection_id'); $collectionId = $input->getOption('collection_id');
$lockStatus = $input->getOption('mail_lock_status'); $lockStatus = $input->getOption('mail_lock_status');
$guest = $input->getOption('guest'); $guest = $input->getOption('guest');
$application = $input->getOption('application');
$withAdress = $input->getOption('adress'); $withAdress = $input->getOption('adress');
$created = $input->getOption('created'); $created = $input->getOption('created');
$updated = $input->getOption('updated'); $updated = $input->getOption('updated');
@@ -77,11 +75,6 @@ class UserListCommand extends Command
if($lockStatus && !$models) $query->addSqlFilter('Users.mail_locked = 1'); if($lockStatus && !$models) $query->addSqlFilter('Users.mail_locked = 1');
if($guest && !$models) $query->include_invite(true)->addSqlFilter('Users.guest = 1'); if($guest && !$models) $query->include_invite(true)->addSqlFilter('Users.guest = 1');
if ($application and !$userId) {
$output->writeln('<error>You must provide --user_id when using --application option</error>');
return 0;
}
/** @var UserRepository $userRepository */ /** @var UserRepository $userRepository */
$userRepository = $this->container['repo.users']; $userRepository = $this->container['repo.users'];
@@ -94,11 +87,7 @@ class UserListCommand extends Command
} }
$userList = []; $userList = [];
$showApplication = false;
foreach ($users as $key => $user) { foreach ($users as $key => $user) {
if ($userId and $application) {
$showApplication = true;
}
$userList[] = $this->listUser($user, $withAdress, $withRight); $userList[] = $this->listUser($user, $withAdress, $withRight);
$userListRaw[] = array_combine($this->headerTable($withAdress, $withRight), $this->listUser($user, $withAdress, $withRight)); $userListRaw[] = array_combine($this->headerTable($withAdress, $withRight), $this->listUser($user, $withAdress, $withRight));
@@ -113,15 +102,6 @@ class UserListCommand extends Command
->setRows($userList) ->setRows($userList)
->render($output); ->render($output);
; ;
if ($showApplication) {
$applicationTable = $this->getHelperSet()->get('table');
$applicationTable->setHeaders(array(
array(new TableCell('Applications', array('colspan' => 5))),
['name','callback','client_secret','client_id','token'],
))->setRows($this->getApplicationOfUser($users[0]))->render($output);
}
} }
@@ -215,37 +195,6 @@ class UserListCommand extends Command
]; ];
} }
/**
* @param User $user
* @return array
*/
private function getApplicationOfUser(User $user)
{
$apiRepository = $this->container['repo.api-applications'];
$applications = $apiRepository->findByUser($user);
if (empty($applications)) {
return [];
}
$accountRepository = $this->container['repo.api-accounts'];
$apiOauthRepository = $this->container['repo.api-oauth-tokens'];
$usersApplication = [];
foreach ($applications as $application) {
$account = $accountRepository->findByUserAndApplication($user, $application);
$token = $account ? $apiOauthRepository->findDeveloperToken($account) : null;
$usersApplication[] = [
$application->getName(),
$application->getRedirectUri(),
$application->getClientSecret(),
$application->getClientId(),
($token) ? $token->getOauthToken() : '-'
];
}
return $usersApplication;
}
/** /**
* @param $withAdress * @param $withAdress
* @param $withRight * @param $withRight

View File

@@ -65,7 +65,7 @@
"normalize-css": "^2.1.0", "normalize-css": "^2.1.0",
"npm": "^6.0.0", "npm": "^6.0.0",
"npm-modernizr": "^2.8.3", "npm-modernizr": "^2.8.3",
"phraseanet-production-client": "0.34.142-d", "phraseanet-production-client": "0.34.146-d",
"requirejs": "^2.3.5", "requirejs": "^2.3.5",
"tinymce": "^4.0.28", "tinymce": "^4.0.28",
"underscore": "^1.8.3", "underscore": "^1.8.3",

View File

@@ -7577,10 +7577,10 @@ phraseanet-common@^0.4.5-d:
js-cookie "^2.1.0" js-cookie "^2.1.0"
pym.js "^1.3.1" pym.js "^1.3.1"
phraseanet-production-client@0.34.142-d: phraseanet-production-client@0.34.146-d:
version "0.34.142-d" version "0.34.146-d"
resolved "https://registry.yarnpkg.com/phraseanet-production-client/-/phraseanet-production-client-0.34.142-d.tgz#9b66d9722e316c9af0ec35c9f497932b70c28c2e" resolved "https://registry.yarnpkg.com/phraseanet-production-client/-/phraseanet-production-client-0.34.146-d.tgz#39e5e61c38a0719d46a3805d8fe3d7a64b0d7c38"
integrity sha512-U4gholdgWgjas16yerS+XqfrTcAhOCMMwXSbj8sapCdHUxy1GnSSelKcx/OTp+IPU/0oWpjT0I6M27azxhA/Sw== integrity sha512-0Flp6UuNiSPTo1rF80NyHjjB7sgP0c13gwtfR8Mzx0Rp7s2NFzgJnh4LXwdhWy+/WCQYnXWuH4XTJuRjmT27RA==
dependencies: dependencies:
"@mapbox/mapbox-gl-language" "^0.9.2" "@mapbox/mapbox-gl-language" "^0.9.2"
"@turf/turf" "^5.1.6" "@turf/turf" "^5.1.6"