Skip to content

Commit c956855

Browse files
authored
Fixed admin:user:create failing when admin role has different name (#592)
1 parent 8101789 commit c956855

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/MahoCLI/Commands/AdminUserCreate.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3131
{
3232
$this->initMaho();
3333

34-
$role = Mage::getModel('admin/roles')
35-
->load('Administrators', 'role_name');
34+
$role = Mage::getModel('admin/roles')->getCollection()
35+
->addFieldToFilter('role_type', 'G')
36+
->addFieldToFilter('tree_level', 1)
37+
->setOrder('role_id', 'ASC')
38+
->getFirstItem();
3639
if (!$role->getId()) {
37-
$output->writeln('<error>Role "Administrators" not found</error>');
40+
$output->writeln('<error>No admin role found</error>');
3841
return Command::FAILURE;
3942
}
4043

@@ -61,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6164
$email = $questionHelper->ask($input, $output, $question);
6265
$email = trim($email);
6366
if (!strlen($email)) {
64-
$output->writeln('<error>Username cannot be empty</error>');
67+
$output->writeln('<error>Email cannot be empty</error>');
6568
return Command::INVALID;
6669
}
6770

0 commit comments

Comments
 (0)