Skip to content

Commit

Permalink
tweak(Admin/Frontend/Cli): improve error/return handling of createJwt…
Browse files Browse the repository at this point in the history
…AccessRoute
  • Loading branch information
pschuele committed Jan 15, 2024
1 parent fd08166 commit b2dbbc1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tine20/Admin/Frontend/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ class Admin_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
),
);

public function createJwtAccessRoute(Zend_Console_Getopt $_opts)
public function createJwtAccessRoute(Zend_Console_Getopt $_opts): int
{
$this->_checkAdminRight();

$args = $this->_parseArgs($_opts, ['account', 'route']);

$accountId = Tinebase_User::getInstance()->getFullUserByLoginName($args['account'])->getId();
try {
$accountId = Tinebase_User::getInstance()->getFullUserByLoginName($args['account'])->getId();
} catch (Tinebase_Exception_NotFound $tenf) {
echo $tenf->getMessage() . "\n";
return 1;
}
$route = (array)$args['route'];

//create new private and public key
// create new private and public key
$new_key_pair = openssl_pkey_new(array(
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
Expand All @@ -76,6 +81,8 @@ public function createJwtAccessRoute(Zend_Console_Getopt $_opts)
Admin_Controller_JWTAccessRoutes::getInstance()->create($jwtAccessRoute);

echo PHP_EOL . $token . PHP_EOL;

return 0;
}

/**
Expand Down

0 comments on commit b2dbbc1

Please sign in to comment.