summaryrefslogtreecommitdiff
path: root/plugins/FBConnect/FBConnectAuth.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/FBConnect/FBConnectAuth.php')
-rw-r--r--plugins/FBConnect/FBConnectAuth.php45
1 files changed, 29 insertions, 16 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;