diff options
author | Paul W. Frields <stickster@gmail.com> | 2010-07-17 15:18:53 -0400 |
---|---|---|
committer | Paul W. Frields <stickster@gmail.com> | 2010-07-17 15:18:53 -0400 |
commit | 8d331c7b5f81d05b1ca7682baecc9b9120e9ecc8 (patch) | |
tree | 4127434a0843cb813b369f86c8d65d559e7143b7 /authfas.module | |
parent | f82ad67428ed5aa1897e1fe96fe3b17bdd1ee5ed (diff) | |
download | drupal-authfas-6x-8d331c7b5f81d05b1ca7682baecc9b9120e9ecc8.tar.gz drupal-authfas-6x-8d331c7b5f81d05b1ca7682baecc9b9120e9ecc8.tar.xz drupal-authfas-6x-8d331c7b5f81d05b1ca7682baecc9b9120e9ecc8.zip |
Add extra headers option for fas_login()
Diffstat (limited to 'authfas.module')
-rw-r--r-- | authfas.module | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/authfas.module b/authfas.module index e199f17..1000b9f 100644 --- a/authfas.module +++ b/authfas.module @@ -117,14 +117,15 @@ function authfas_menu() { return $items; } -function fas_login($username, $password, $url) { +function fas_login($username, $password, $url, $headers) { $username = strtolower($username); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login"); - curl_setopt($ch, CURLOPT_USERAGENT, "Drupal AuthFAS 0.1;"); + // Sticking extra headers in user agent string for now, no other good CURLOPT? + curl_setopt($ch, CURLOPT_USERAGENT, "Drupal AuthFAS 0.1; ".$headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -148,7 +149,7 @@ function authfas_admin_validate($form, &$form_state) { $password = $form_state['values']['fas_password']; if (($username != '') and ($password != '')) { - $response = fas_login($username, $password, 'https://'.$fasurl.'/json/'); + $response = fas_login($username, $password, 'https://'.$fasurl.'/json/', 'Accept: application/json;'); if (!isset($response["help"])) { form_set_error("authfas_fasurl", t('No JSON interface present at https://'.$fasurl.'/json/ or could not verify username "'.$username.'".')); |