I am looking for the API that will let me login a user by passing it the username and password. Does anyone have experience with this?
To clarify, I am trying to make an AJAX login box that appears as a popup on the home page, and do not refresh the page in case of wrong credentials, but only if the log in is correct. So here is what i have done so far:
Update
I now load the login form on my homepage, then on submission I launch an AJAX request that sends credential to this script:
function user_login_submit_try() {
global $user;
$uid = user_authenticate($_POST['name'],$_POST['pass']);
$arr = array ('name'=>$_POST['name'],'pass'=>$_POST['pass']);
if ($uid){
$user = user_load($uid);
user_login_finalize($arr);
}
echo drupal_json_encode($uid);
exit;
};
So far it works, but my worries are (as mentioned by googletorp) security issues; it seems that none of the API I used in this script sanitized the data in anyway.
Would anyone see a better way to do so?