Add some logging and a warning about CURLOPT_VERBOSE.

This commit is contained in:
Ricky Zhou (周家杰) 2009-07-26 10:38:23 -04:00
parent d8ef5c36ac
commit c5a53944fc

View file

@ -9,7 +9,7 @@ Author URI: http://fedoraproject.org/wiki/Infrastructure
*/
// overriding wp_authenticate
if(!function_exists('wp_authenticate')) :
if (!function_exists('wp_authenticate')) {
// let's disable a few things
add_action('lost_password', 'disable_function');
@ -44,7 +44,11 @@ function wp_authenticate($username, $password) {
curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9");
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode($username)."&user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
# WARNING: Never leave this on in production, as it will cause
# plaintext passwords to show up in error logs.
curl_setopt($ch, CURLOPT_VERBOSE, 0);
$fasuserdata = json_decode(curl_exec($ch), true);
curl_close ($ch);
@ -53,6 +57,7 @@ function wp_authenticate($username, $password) {
// check minimum requirements
if (check_login_requirement($fasuserdata) !== true) {
fwrite(STDERR, "FAS auth failed for $username: insufficient group membership\n");
return new WP_Error('fasauth_min_requirement', __('<strong>Error</strong>: You do not meet minimum requirements to login.'));
}
@ -66,13 +71,16 @@ function wp_authenticate($username, $password) {
return new WP_Error('fasauth_create_wp_user', __('<strong>Error</strong>: Unable to create account. Please contact the webmaster.'));
}
fwrite(STDERR, "FAS auth succeeded for $username\n");
return new WP_User($user_id);
}
// all good, let go on
fwrite(STDERR, "FAS auth succeeded for $username\n");
return new WP_User($user->ID);
} else {
fwrite(STDERR, "FAS auth failed for $username: incorrect username or password\n");
return new WP_Error('fasauth_wrong_credentials', __('<strong>Error</strong>: FAS login unsuccessful.'));
}
}
@ -129,6 +137,6 @@ function check_login_requirement($user) {
return false;
}
endif;
}
?>