CB ajax login
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9108
- Karma: 1434
1 year 2 weeks ago #333802
by krileon
Global
Triggers: None
Type: Registration
User: Self
Access: Everybody
Action
Username: autoactionregistration
Email: autoactionregistration@cb.invalid
Name: autoactionregistration
Output
Display: return
Layout:
Method: PHP
The user registers and it shows their username when accessing the auto action URL directly from browser. This confirms the registration process works. Any problems with it would be a problem with the data passed to it or possibly anything acting on Joomla user store or CB registration triggers as this auto action will fire normal 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.
Replied by krileon on topic CB ajax login
Works fine in my tests. My guess is the user store is failing due to missing critical data. Ensure you're supplying username, email address, and name. Those are all required by Joomla. If password isn't provided it can generate one if the parameter is left empty. Example as follows.Ok for this, but I need help with the CB register autoaction that I may use to register users and which is not working whatever I tried
Even with a postman request there is no success.
Global
Triggers: None
Type: Registration
User: Self
Access: Everybody
Action
Username: autoactionregistration
Email: autoactionregistration@cb.invalid
Name: autoactionregistration
Output
Display: return
Layout:
Code:
return $actiondata['data1']->username;
The user registers and it shows their username when accessing the auto action URL directly from browser. This confirms the registration process works. Any problems with it would be a problem with the data passed to it or possibly anything acting on Joomla user store or CB registration triggers as this auto action will fire normal 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
- OFFLINE
- Posts: 2279
- Thanks: 113
- Karma: 13
1 year 2 weeks ago #333803
by activha
Replied by activha on topic CB ajax login
It does not work with [post_fields] with Postman or my fetch function in javascript.
I can register a user like you did but the user is only registered as joomla user and does not appear as CB user.
Tried to use a fetch function like this one
I can register a user like you did but the user is only registered as joomla user and does not appear as CB user.
Tried to use a fetch function like this one
Code:
async registerUserAjax() {
const name = this.shadowRoot.getElementById('reg_name').value;
const firstname = this.shadowRoot.getElementById('reg_firstname').value;
const email = this.shadowRoot.getElementById('reg_email').value;
const username = this.shadowRoot.getElementById('reg_username').value;
const password = this.shadowRoot.getElementById('reg_password').value;
const data = {
lastname: name,
firstname: firstname,
email: email,
username: username,
password: password
};
const requestOptions = {
method: 'POST',
body: JSON.stringify(data)
};
// Remplacez "AUTOACTION_URL_HERE" par l'URL réelle pour enregistrer un nouvel utilisateur
try {
const response = await fetch(`${domain}/index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=330&Itemid=9343&format=raw`, requestOptions);
if (!response.ok) {
throw new Error(response.statusText);
}
const responseData = await response.json();
console.log("Texte de la réponse:", JSON.stringify(responseData));
if (responseData.success) {
console.log('Inscription réussie');
const token = responseData.token;
const firstname = responseData.firstname;
if (token) {
localStorage.setItem(page + "_token", token);
localStorage.setItem(page + "_isLoggedIn", 1);
localStorage.setItem(page + "_firstname", firstname);
await updateWebComponentState(true);
} else {
console.log('Token vide. Vérifiez la réponse du serveur.');
}
} else {
console.log('Échec de l\'inscription');
alert('Échec de l\'inscription. Veuillez vérifier les informations fournies. Votre identifiant ne doit comporter que des lettres et des chiffres, sans espaces.');
}
} catch (error) {
console.error('Error:', error);
alert('Une erreur s\'est produite lors de l\'inscription. Veuillez réessayer.');
}
}
Please Log in or Create an account to join the conversation.
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9108
- Karma: 1434
1 year 2 weeks ago - 1 year 2 weeks ago #333804
by krileon
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.
Replied by krileon on topic CB ajax login
Then there's a problem with how data is being sent via POST. You can access request and get variables too (e.g. [request_name], [get_name]). Use whatever is necessary for your needs. Based off your sample you are not sending POST data correctly. You're sending a JSON encoded string. Use FormData to properly send a POST body object.It does not work with [post_fields] with Postman or my fetch function in javascript.
Then you have something acting on Joomla user store behavior interrupting the process.I can register a user like you did but the user is only registered as joomla user and does not appear as CB user.
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.
Last edit: 1 year 2 weeks ago by krileon.
Please Log in or Create an account to join the conversation.
- activha
- OFFLINE
- Posts: 2279
- Thanks: 113
- Karma: 13
1 year 2 weeks ago #333806
by activha
Replied by activha on topic CB ajax login
Ok thanks for the tip, got it working but I have the same issue than with the login autoaction.
The autoaction issues a redirection and I'd only want a json return with the data.
Could you add the same option as for the CB Login autoaction ? that would be great
The autoaction issues a redirection and I'd only want a json return with the data.
Could you add the same option as for the CB Login autoaction ? that would be great
Please Log in or Create an account to join the conversation.
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9108
- Karma: 1434
1 year 2 weeks ago - 1 year 2 weeks ago #333807
by krileon
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.
Replied by krileon on topic CB ajax login
The redirect is optional in latest CB Auto Actions release. See my reply below on how to not redirect. Example provided.
www.joomlapolis.com/forum/developer-members-support/245815-cb-ajax-login?start=6#333741
Don't leave the redirect parameter empty you need to actually set it to "none" (without quotes).
www.joomlapolis.com/forum/developer-members-support/245815-cb-ajax-login?start=6#333741
Don't leave the redirect parameter empty you need to actually set it to "none" (without quotes).
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.
Last edit: 1 year 2 weeks ago by krileon.
Please Log in or Create an account to join the conversation.
- activha
- OFFLINE
- Posts: 2279
- Thanks: 113
- Karma: 13
1 year 2 weeks ago - 1 year 2 weeks ago #333808
by activha
Replied by activha on topic CB ajax login
Yes I got it but my point was with CB Autoaction Registration, not login
Don't know if there is a redirect in CB Autoaction register ?
It may be that I have an autoaction to automatically log users after registration so I think I will try to avoid the last one
Would this work in the conditions to avoid the CB Register autoaction ?
Edit : it seems like the above is working
Don't know if there is a redirect in CB Autoaction register ?
It may be that I have an autoaction to automatically log users after registration so I think I will try to avoid the last one
Would this work in the conditions to avoid the CB Register autoaction ?
Code:
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
$app = Factory::getApplication();
$uri = new Uri($app->input->server->get('HTTP_REFERER', '', 'string'));
if (strpos($uri->toString(), 'actions=330') !== false) {
return false;
} else {
return true;
}
EGAL
true
Edit : it seems like the above is working
Last edit: 1 year 2 weeks ago by activha.
Please Log in or Create an account to join the conversation.
Moderators: beat, nant, krileon