Advertisement
access Joomla from an external application
Moderators: ooffick, General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sun Oct 06, 2024 4:18 pm
access Joomla from an external application
How can I access Joomla from an external application? I followed what is written in the documentation
https://docs.joomla.org/J4.x:Creating_a ... for_Joomla
I send a post request with username and password and I receive the code 200 but it does not connect to the site. In short, if I check the administrator side the user is not connected. What am I doing wrong? Any help would be a gift.
Thanks in advance
https://docs.joomla.org/J4.x:Creating_a ... for_Joomla
I send a post request with username and password and I receive the code 200 but it does not connect to the site. In short, if I check the administrator side the user is not connected. What am I doing wrong? Any help would be a gift.
Thanks in advance
Last edited by imanickam on Sun Oct 06, 2024 4:38 pm, edited 1 time in total.
Reason: Moved topic from General Questions/New to Joomla! 5.x to Joomla! 5.x Coding
Reason: Moved topic from General Questions/New to Joomla! 5.x to Joomla! 5.x Coding
Advertisement
- Per Yngve Berg
- Joomla! Master
- Posts: 31347
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: access Joomla from an external application
I don't understand what you are trying to achieve. Have you written your own Authentication Plugin?
An Authentication Plugin let Joomla verify the credentials somewhere else than the Joomla Database.
Can you post your code?
An Authentication Plugin let Joomla verify the credentials somewhere else than the Joomla Database.
Can you post your code?
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sun Oct 06, 2024 4:18 pm
Re: access Joomla from an external application
First of all, thank you for writing to me..
The code is as follows:
The code is as follows:
Code: Select all
<?php
/**
* @package Joomla.Login
* @subpackage Authentication.login
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
use Joomla\CMS\Authentication\Authentication;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\User\User;
use Joomla\Event\SubscriberInterface;
/**
* Example Authentication Plugin for the Joomla Docs.
*
* @since 1.0
*/
class PlgAuthenticationLogin extends CMSPlugin implements SubscriberInterface
{
/**
* Database object
*
* @var \Joomla\Database\DatabaseDriver
* @since 1.0
*/
protected $db;
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since 1.0
*/
public static function getSubscribedEvents(): array
{
return [
'onUserAuthenticate' => 'onUserAuthenticate',
];
}
/**
* Questo metodo dovrebbe gestire qualsiasi autenticazione e inviare un report al soggetto
* Questo esempio utilizza un'autenticazione semplice: controlla se la password è l'inverso
* del nome utente (e se l'utente esiste nel database).
*
* @access public
* @param array $credentials Array holding the user credentials ('username' and 'password')
* @param array $options Array of extra options
* @param object $response Authentication response object
*
* @return boolean
*
* @since 1.0
*/
public function onUserAuthenticate( $credentials, $options, &$response )
{
/*
* Qui faresti tutto ciò di cui hai bisogno per una routine di autenticazione con le credenziali
* In questo esempio la variabile mista $return verrebbe impostata su false
* se la routine di autenticazione fallisce o un intero userid dell'utente autenticato
* se la routine passa
*/
$query = $this->db->getQuery(true)
->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__users'))
->where($this->db->quoteName('username') . ' = :username')
->bind(':username', $credentials['username']);
$this->db->setQuery($query);
$result = $this->db->loadResult();
if (!$result)
{
$response->status = Authentication::STATUS_FAILURE;
$response->error_message = 'User does not exist';
}
/**
* Per l'autenticazione, il nome utente deve esistere nel database e la password deve essere uguale
* al contrario del nome utente (quindi l'utente joeblow avrebbe password wolbeoj)
* if($result && ($credentials['username'] == strrev( $credentials['password'] )))
*/
if($result && ($credentials['username']))
{
$email = User::getInstance($result); // Bring this in line with the rest of the system
$response->email = $email->email;
$response->status = Authentication::STATUS_SUCCESS;
}
else
{
$response->status = Authentication::STATUS_FAILURE;
$response->error_message = 'Invalid username and password';
}
}
}
Last edited by Per Yngve Berg on Sun Oct 06, 2024 5:58 pm, edited 1 time in total.
Reason: Added Code Tags
Reason: Added Code Tags
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sun Oct 06, 2024 4:18 pm
Re: access Joomla from an external application
I write the codePer Yngve Berg wrote: ↑Sun Oct 06, 2024 5:10 pm I don't understand what you are trying to achieve. Have you written your own Authentication Plugin?
An Authentication Plugin let Joomla verify the credentials somewhere else than the Joomla Database.
Can you post your code?
- sakiss
- Joomla! Explorer
- Posts: 373
- Joined: Wed Aug 20, 2008 4:09 pm
Re: access Joomla from an external application
I don't know what you want to do, but possibly the way to go is through the Joomla REST Api
https://docs.joomla.org/J4.x:Joomla_Core_APIs
At least that's the indicated way to communicate with Joomla from another app
https://docs.joomla.org/J4.x:Joomla_Core_APIs
At least that's the indicated way to communicate with Joomla from another app
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sun Oct 06, 2024 4:18 pm
Re: access Joomla from an external application
Thank you for your reply and I apologize for the late reply on my part but unfortunately I can only access the forum from the office and I was not present these days. However, what I want to do is simply connect a user via an external application. I do not want to use the API for a series of reasons that I will not list because it would be too long.
-
- Joomla! Enthusiast
- Posts: 244
- Joined: Sat Mar 04, 2017 1:28 am
- Location: Surrey, UK
- Contact:
Re: access Joomla from an external application
That makes no sense to me, you must have a "task" in mind for the user. Otherwise, what would be the point in just connecting the user?EmanuelePe wrote: ↑Thu Oct 10, 2024 12:56 pm what I want to do is simply connect a user via an external application. I do not want to use the API for a series of reasons that I will not list because it would be too long.
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sun Oct 06, 2024 4:18 pm
Re: access Joomla from an external application
The user needs to connect and download a file. That's it.brendanhedges wrote: ↑Mon Oct 21, 2024 9:15 pmThat makes no sense to me, you must have a "task" in mind for the user. Otherwise, what would be the point in just connecting the user?EmanuelePe wrote: ↑Thu Oct 10, 2024 12:56 pm what I want to do is simply connect a user via an external application. I do not want to use the API for a series of reasons that I will not list because it would be too long.
Advertisement