Skip to Content Skip to Menu

CB login authentication token

  • activha
  • activha
  • OFFLINE
  • Posts: 2280
  • Thanks: 113
  • Karma: 13
1 year 1 month ago #333332 by activha
Replied by activha on topic CB login authentication token
yes I tried to use this combination, so the user would add a cb_token field and the API token would be generated. That seems a nice way to do it.

However the issue that I have is that the cb_api_token field seems to be changed at each display of the user profile so I cannot get the user to be retrieved in the autoaction.

Do you have an idea to keep the cb_api_token until the cb_token is changed by the user ? and also can I use an ajax display in profile edit when the cb_token is edited to display the cb_api_token updated ?
Code:
cb_token: text /validation one word only with letters and numbers cb_api_token : return ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]]' ) )->encryptString( (string) \CBLib\Application\Application::MyUser()->getUserId() ); autoaction user code: return (int) ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->decryptString( '[get_token]' );
 

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
1 year 1 month ago #333336 by krileon
Replied by krileon on topic CB login authentication token
Generated tokens like that will change on every display. The old token will still work though. You could use CB Auto Actions to store the result to a field I suppose using a Code action. Example as follows.

Code:
$user->set( 'cb_api_token', ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->encryptString( (string) \CBLib\Application\Application::MyUser()->getUserId() ) ); $user->store();

That'd store it to cb_api_token field. You'd do this on profile update and registration triggers.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • activha
  • activha
  • OFFLINE
  • Posts: 2280
  • Thanks: 113
  • Karma: 13
1 year 1 month ago #333344 by activha
Replied by activha on topic CB login authentication token
I tried your last suggestion in a code autoaction:
code : PHP
user : automatic
access : everybody
output : none or silent
format function : yes

But I cannot get it to save something in cb_api_token which I changed to be a read only text field

any idea of what's wrong ?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
1 year 1 month ago #333356 by krileon
Replied by krileon on topic CB login authentication token
What triggers are you using? You'd probably need to use the below to deal with backend/frontend profile edit and registration.

onAfterUserUpdate
onAfterUpdateUser
onAfterUserRegistration
onAfterNewUser


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • activha
  • activha
  • OFFLINE
  • Posts: 2280
  • Thanks: 113
  • Karma: 13
1 year 1 month ago #333360 by activha
Replied by activha on topic CB login authentication token
yes exactly what I use, but something fails somewhere.
The field cb_api_token is on a tab which is only displayed to CBsubs plans and is restricted now to special group. Can it be an issue ?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
1 year 1 month ago #333363 by krileon
Replied by krileon on topic CB login authentication token
The example provided above directly stores to the user object. It does not care about permissions. I did not test it however so it could have errors. Might be the $_CB_framework usage. Try adding global $_CB_framework; above the field set. Example as follows.
Code:
global $_CB_framework; $user->set( 'cb_api_token', ( new \Joomla\CMS\Encrypt\Aes( $_CB_framework->getCfg( 'secret' ) . ':[cb_token]' ) )->encryptString( (string) \CBLib\Application\Application::MyUser()->getUserId() ) ); $user->store();


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn