Oupss seems I spoke too quickly, it's fine to encrypt and store the API token with the code, but the autoaction to decrypt always return null for the variable $userid.
The encrypt autoaction code is :
Code:
global $_CB_framework;
$user->set( 'cb_token_api', ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->encryptString( (string) \CBLib\Application\Application::MyUser()->getUserId() ) );
$user->store();
And the decrypt autoaction code is :
Code:
global $_CB_framework;
return (int) ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->decryptString( '[get_token]' );
I properly set code instead of query to retrieve the user in the second autoaction and removed format function
The url is correct : website/?token=cb_token_api
Any idea of what I could have missed ?
EDIT:
I tried also
Code:
return (int) ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->decryptString( '[cb:parse function="clean" method="string"][get_token][/cb:parse]' );
but it's still gives null also