addArgument('tenant', InputArgument::REQUIRED, 'Tenant identifier') ->addArgument('identity', InputArgument::REQUIRED, 'User identity (email/username)') ->addArgument('password', InputArgument::OPTIONAL, 'Password (prompted for interactively when omitted)') ->setHelp('This command sets or updates the password credential for a user account. Omit the password argument to be prompted securely.') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $tenant = $input->getArgument('tenant'); $identity = $input->getArgument('identity'); $password = $input->getArgument('password'); $io->title('Set User Password'); try { if (!$this->tenantService->fetchById($tenant)) { $io->error("Tenant '{$tenant}' not found."); return Command::FAILURE; } if (!$this->userStore->fetchByIdentity($tenant, $identity)) { $io->error("User '{$identity}' not found in tenant '{$tenant}'."); return Command::FAILURE; } if ($password === null) { $password = $io->askHidden('Password'); } if (empty($password)) { $io->error('Password cannot be empty.'); return Command::FAILURE; } if (!$this->provider->setCredential($tenant, $identity, $password)) { $io->error("Failed to store password credential for '{$identity}'."); return Command::FAILURE; } $this->logger->info('User password credential set via console', [ 'tenant' => $tenant, 'identity' => $identity, 'command' => $this->getName(), ]); $io->success("Password credential for '{$identity}' stored successfully!"); return Command::SUCCESS; } catch (\Throwable $e) { $io->error('Failed to set password: ' . $e->getMessage()); $this->logger->error('User password set failed', [ 'tenant' => $tenant, 'identity' => $identity, 'error' => $e->getMessage(), ]); return Command::FAILURE; } } }