diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-08-18 23:41:24 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-08-18 23:46:24 +0000 |
commit | 8507017c246bef32f58d58db7d0b639f7f8f8668 (patch) | |
tree | b8c8e3c7fcfaa56a922f9fc3cd308b318327dbe8 | |
parent | c049931dc735d7767c5199d2d2816edb5f0487a2 (diff) |
Better logging
-rw-r--r-- | plugins/FBConnect/FBConnectAuth.php | 45 | ||||
-rw-r--r-- | plugins/FBConnect/FBConnectPlugin.php | 12 | ||||
-rw-r--r-- | plugins/FBConnect/FBConnectSettings.php | 6 |
3 files changed, 39 insertions, 24 deletions
diff --git a/plugins/FBConnect/FBConnectAuth.php b/plugins/FBConnect/FBConnectAuth.php index 5b9d604e3..6191d9ea6 100644 --- a/plugins/FBConnect/FBConnectAuth.php +++ b/plugins/FBConnect/FBConnectAuth.php @@ -31,7 +31,6 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php'; class FBConnectauthAction extends Action { - var $fbuid = null; var $fb_fields = null; @@ -44,6 +43,11 @@ class FBConnectauthAction extends Action $this->fb_fields = $this->getFacebookFields($this->fbuid, array('first_name', 'last_name', 'name')); } else { + list($proxy, $ip) = common_client_ip(); + + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . + "Failed auth attempt, proxy = $proxy, ip = $ip."); + $this->clientError(_('You must be logged into Facebook to ' . 'use Facebook Connect.')); } @@ -63,8 +67,9 @@ class FBConnectauthAction extends Action if (!empty($flink)) { // User already has a linked Facebook account and shouldn't be here - common_debug('There is already a local user (' . $flink->user_id . - ') linked with this Facebook (' . $this->fbuid . ').'); + common_debug('Facebook Connect Plugin - ' . + 'There is already a local user (' . $flink->user_id . + ') linked with this Facebook (' . $this->fbuid . ').'); // We don't want these cookies getFacebook()->clear_cookie_state(); @@ -95,7 +100,8 @@ class FBConnectauthAction extends Action } else if ($this->arg('connect')) { $this->connectNewUser(); } else { - common_debug(print_r($this->args, true), __FILE__); + common_debug('Facebook Connect Plugin - ' . + print_r($this->args, true)); $this->showForm(_('Something weird happened.'), $this->trimmed('newname')); } @@ -205,7 +211,6 @@ class FBConnectauthAction extends Action function createNewUser() { - if (common_config('site', 'closed')) { $this->clientError(_('Registration not allowed.')); return; @@ -268,7 +273,8 @@ class FBConnectauthAction extends Action common_set_user($user); common_real_login(true); - common_debug("Registered new user $user->id from Facebook user $this->fbuid"); + common_debug('Facebook Connect Plugin - ' . + "Registered new user $user->id from Facebook user $this->fbuid"); common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303); @@ -286,8 +292,9 @@ class FBConnectauthAction extends Action $user = User::staticGet('nickname', $nickname); - if ($user) { - common_debug("Legit user to connect to Facebook: $nickname"); + if (!empty($user)) { + common_debug('Facebook Connect Plugin - ' . + "Legit user to connect to Facebook: $nickname"); } $result = $this->flinkUser($user->id, $this->fbuid); @@ -297,7 +304,8 @@ class FBConnectauthAction extends Action return; } - common_debug("Connected Facebook user $this->fbuid to local user $user->id"); + common_debug('Facebook Connnect Plugin - ' . + "Connected Facebook user $this->fbuid to local user $user->id"); common_set_user($user); common_real_login(true); @@ -311,12 +319,13 @@ class FBConnectauthAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); - if (!$result) { + if (empty($result)) { $this->serverError(_('Error connecting user to Facebook.')); return; } - common_debug("Connected Facebook user $this->fbuid to local user $user->id"); + common_debug('Facebook Connect Plugin - ' . + "Connected Facebook user $this->fbuid to local user $user->id"); // Return to Facebook connection settings tab common_redirect(common_local_url('FBConnectSettings'), 303); @@ -324,16 +333,18 @@ class FBConnectauthAction extends Action function tryLogin() { - common_debug("Trying Facebook Login..."); + common_debug('Facebook Connect Plugin - ' . + "Trying login for Facebook user $this->fbuid."); $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_CONNECT_SERVICE); - if ($flink) { + if (!empty($flink)) { $user = $flink->getUser(); if (!empty($user)) { - common_debug("Logged in Facebook user $flink->foreign_id as user $user->id ($user->nickname)"); + common_debug('Facebook Connect Plugin - ' . + "Logged in Facebook user $flink->foreign_id as user $user->id ($user->nickname)"); common_set_user($user); common_real_login(true); @@ -342,7 +353,8 @@ class FBConnectauthAction extends Action } else { - common_debug("No flink found for fbuid: $this->fbuid"); + common_debug('Facebook Connect Plugin - ' . + "No flink found for fbuid: $this->fbuid - new user"); $this->showForm(null, $this->bestNewNickname()); } @@ -438,7 +450,8 @@ class FBConnectauthAction extends Action return reset($infos); } catch (Exception $e) { - common_log(LOG_WARNING, "Facebook client failure when requesting " . + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . + "Facebook client failure when requesting " . join(",", $fields) . " on uid " . $fb_uid . " : ". $e->getMessage()); return null; diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index fd16d2bf1..c1bd1c094 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -214,7 +214,7 @@ class FBConnectPlugin extends Plugin $fbuid = $facebook->get_loggedin_user(); } catch (Exception $e) { - common_log(LOG_WARNING, + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . 'Problem getting Facebook user: ' . $e->getMessage()); } @@ -342,7 +342,7 @@ class FBConnectPlugin extends Plugin } function onStartLogout($action) - { +{ $action->logout(); $fbuid = $this->loggedIn(); @@ -351,8 +351,9 @@ class FBConnectPlugin extends Plugin $facebook = getFacebook(); $facebook->expire_session(); } catch (Exception $e) { - common_log(LOG_WARNING, 'Could\'t logout of Facebook: ' . - $e->getMessage()); + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . + 'Could\'t logout of Facebook: ' . + $e->getMessage()); } } @@ -376,7 +377,8 @@ class FBConnectPlugin extends Plugin } } catch (Exception $e) { - common_log(LOG_WARNING, "Facebook client failure requesting profile pic!"); + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . + "Facebook client failure requesting profile pic!"); } return $url; diff --git a/plugins/FBConnect/FBConnectSettings.php b/plugins/FBConnect/FBConnectSettings.php index 034ecebae..d1bea0854 100644 --- a/plugins/FBConnect/FBConnectSettings.php +++ b/plugins/FBConnect/FBConnectSettings.php @@ -186,9 +186,9 @@ class FBConnectSettingsAction extends ConnectSettingsAction $facebook->clear_cookie_state(); } catch (Exception $e) { - common_log(LOG_WARNING, - 'Couldn\'t clear Facebook cookies: ' . - $e->getMessage()); + common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . + 'Couldn\'t clear Facebook cookies: ' . + $e->getMessage()); } $this->showForm(_('You have disconnected from Facebook.'), true); |