Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Using the Ouput parameters you can have your auto action return whatever you want. Basically check if they've a user id after doing the login action and if they do they're logged in. If they don't they aren't. So you could return true/false, JSON, etc.. as you please based off that.Yes I was thinking also as a Login/Logout action. I only need it to return a yes/no json to allow the user
As I use a webcomponent and not an iframe I'm able to access the cookies on the external domains with our own domain cookies. So I imagined that asking a login via ajax, then getting back the main domain cookies would be enough to allow the user to use the web component.
Token authentication won't work here then.Thinking at joomla 4 token, I have seen this but cannot really imagine how to use them. The process has to be really simple for a user : just login with its username/pass anywhere when the web component is available and then access its content.
Just post to your auto action url (leave Triggers as None for direct access support). It's a component endpoint like any extension. You can access your POST data using substitutions (e.g. [post_username]).Do you know how I could access the autoaction to try ? with a simple form to send user/pass
Please Log in to join the conversation.
loginUserAjax() {
const username = this.shadowRoot.getElementById('username').value;
const password = this.shadowRoot.getElementById('password').value;
const formData = new FormData();
formData.append('username', username);
formData.append('password', password);
// formData.append('option', 'com_ajax');
// formData.append('plugin', 'userloginajax');
// formData.append('format', 'json');
const requestOptions = {
method: 'POST',
body: formData,
};
fetch('https://devel.cercle.business/index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=327&Itemid=9343', requestOptions)
.then(response => response.json())
.then(data => {
if (data.success) {
// Connexion réussie, mettez à jour l'interface utilisateur en conséquence
console.log('Connexion réussie');
// Mettez à jour l'état et l'interface utilisateur de votre web component
updateWebComponentState(true);
} else {
// Échec de la connexion, affichez un message d'erreur
console.log('Échec de la connexion');
alert('Échec de la connexion. Veuillez vérifier votre nom d\'utilisateur et votre mot de passe.');
}
})
.catch(error => {
console.error('Error:', error);
alert('Une erreur s\'est produite lors de la connexion. Veuillez réessayer.');
});
}
updateWebComponentState(isLoggedIn) {
// Mettez à jour l'état de votre web component et l'interface utilisateur en fonction de la valeur de 'isLoggedIn'
// Par exemple, vous pouvez cacher le formulaire de connexion et afficher un message de bienvenue
if (isLoggedIn) {
this.shadowRoot.getElementById('ajaxLoginForm').style.display = 'none';
this.shadowRoot.getElementById('welcomeMessage').style.display = 'block';
} else {
this.shadowRoot.getElementById('ajaxLoginForm').style.display = 'block';
this.shadowRoot.getElementById('welcomeMessage').style.display = 'none';
}
}
Please Log in to join the conversation.
Please Log in to join the conversation.