Closed tareko closed 4 years ago
This is quite undocumented, but it might work:
Ignoring above re: OAuth2, it seems that won't work as well as just using the drupal API for login.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_authenticate/7.x
Sample code:
function user_authenticate($name, $password) {
$uid = FALSE;
if (!empty($name) && !empty($password)) {
$account = user_load_by_name($name);
if ($account) {
// Allow alternate password hashing schemes.
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
if (user_check_password($password, $account)) {
// Successful authentication.
$uid = $account->uid;
// Update user to new password scheme if needed.
if (user_needs_new_hash($account)) {
user_save($account, array('pass' => $password));
}
}
}
}
return $uid;
}
How to bootstrap Drupal (probably overkill, but not a bad start to test / dev):
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_bootstrap/7.x
define('DRUPAL_ROOT', '/path/to/drupal');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
$variables['url'] = 'http://example.com';
drupal_override_server_variables($variables);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Wontfix. Moved to LDAP
Authenticate the user against Drupal API instead of the joomla DB