Sedikit berbagi pengalaman gan. Berawal dari tututan pekerjaan untuk membuat aplikasi authentifikasi user joomla, setelah googling akhirnya dapatlah contoh.
Langsung aja, berikut ini adalah contoh coding untuk authentifikasi user pada joomla yang sedidit telah domodif.
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla'. DS . 'plugin' . DS . 'helper.php');
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla'. DS . 'user' . DS . 'authentication.php');
$mainframe =& JFactory::getApplication('site');
$unm = "UserAdmin";
$pas = "passAdmin";
$credentials = array(
'username' => $unm,
'password' => $pas);
$options = array();
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);
if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) {
$user = JFactory::getUser($unm);
$id =$user->id;
$usernm =$user->username;
$nm =$user->name;
$gid =$user->gid;
$usertype =$user->usertype;
echo "Selamat datang " . $nm;
}else{
echo "Username atau password salah";
}
Sekian, moga bermanfaat.
Wassalaam
Langsung aja, berikut ini adalah contoh coding untuk authentifikasi user pada joomla yang sedidit telah domodif.
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla'. DS . 'plugin' . DS . 'helper.php');
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla'. DS . 'user' . DS . 'authentication.php');
$mainframe =& JFactory::getApplication('site');
$unm = "UserAdmin";
$pas = "passAdmin";
$credentials = array(
'username' => $unm,
'password' => $pas);
$options = array();
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);
if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) {
$user = JFactory::getUser($unm);
$id =$user->id;
$usernm =$user->username;
$nm =$user->name;
$gid =$user->gid;
$usertype =$user->usertype;
echo "Selamat datang " . $nm;
}else{
echo "Username atau password salah";
}
Sekian, moga bermanfaat.
Wassalaam