forked from GNUsocial/gnu-social
Better logging
This commit is contained in:
parent
c049931dc7
commit
8507017c24
@ -31,7 +31,6 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php';
|
|||||||
|
|
||||||
class FBConnectauthAction extends Action
|
class FBConnectauthAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
var $fbuid = null;
|
var $fbuid = null;
|
||||||
var $fb_fields = null;
|
var $fb_fields = null;
|
||||||
|
|
||||||
@ -44,6 +43,11 @@ class FBConnectauthAction extends Action
|
|||||||
$this->fb_fields = $this->getFacebookFields($this->fbuid,
|
$this->fb_fields = $this->getFacebookFields($this->fbuid,
|
||||||
array('first_name', 'last_name', 'name'));
|
array('first_name', 'last_name', 'name'));
|
||||||
} else {
|
} 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 ' .
|
$this->clientError(_('You must be logged into Facebook to ' .
|
||||||
'use Facebook Connect.'));
|
'use Facebook Connect.'));
|
||||||
}
|
}
|
||||||
@ -63,7 +67,8 @@ class FBConnectauthAction extends Action
|
|||||||
if (!empty($flink)) {
|
if (!empty($flink)) {
|
||||||
|
|
||||||
// User already has a linked Facebook account and shouldn't be here
|
// User already has a linked Facebook account and shouldn't be here
|
||||||
common_debug('There is already a local user (' . $flink->user_id .
|
common_debug('Facebook Connect Plugin - ' .
|
||||||
|
'There is already a local user (' . $flink->user_id .
|
||||||
') linked with this Facebook (' . $this->fbuid . ').');
|
') linked with this Facebook (' . $this->fbuid . ').');
|
||||||
|
|
||||||
// We don't want these cookies
|
// We don't want these cookies
|
||||||
@ -95,7 +100,8 @@ class FBConnectauthAction extends Action
|
|||||||
} else if ($this->arg('connect')) {
|
} else if ($this->arg('connect')) {
|
||||||
$this->connectNewUser();
|
$this->connectNewUser();
|
||||||
} else {
|
} 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->showForm(_('Something weird happened.'),
|
||||||
$this->trimmed('newname'));
|
$this->trimmed('newname'));
|
||||||
}
|
}
|
||||||
@ -205,7 +211,6 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
function createNewUser()
|
function createNewUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (common_config('site', 'closed')) {
|
if (common_config('site', 'closed')) {
|
||||||
$this->clientError(_('Registration not allowed.'));
|
$this->clientError(_('Registration not allowed.'));
|
||||||
return;
|
return;
|
||||||
@ -268,7 +273,8 @@ class FBConnectauthAction extends Action
|
|||||||
common_set_user($user);
|
common_set_user($user);
|
||||||
common_real_login(true);
|
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)),
|
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
|
||||||
303);
|
303);
|
||||||
@ -286,8 +292,9 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
if ($user) {
|
if (!empty($user)) {
|
||||||
common_debug("Legit user to connect to Facebook: $nickname");
|
common_debug('Facebook Connect Plugin - ' .
|
||||||
|
"Legit user to connect to Facebook: $nickname");
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->flinkUser($user->id, $this->fbuid);
|
$result = $this->flinkUser($user->id, $this->fbuid);
|
||||||
@ -297,7 +304,8 @@ class FBConnectauthAction extends Action
|
|||||||
return;
|
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_set_user($user);
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
@ -311,12 +319,13 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
$result = $this->flinkUser($user->id, $this->fbuid);
|
$result = $this->flinkUser($user->id, $this->fbuid);
|
||||||
|
|
||||||
if (!$result) {
|
if (empty($result)) {
|
||||||
$this->serverError(_('Error connecting user to Facebook.'));
|
$this->serverError(_('Error connecting user to Facebook.'));
|
||||||
return;
|
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
|
// Return to Facebook connection settings tab
|
||||||
common_redirect(common_local_url('FBConnectSettings'), 303);
|
common_redirect(common_local_url('FBConnectSettings'), 303);
|
||||||
@ -324,16 +333,18 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
function tryLogin()
|
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);
|
$flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_CONNECT_SERVICE);
|
||||||
|
|
||||||
if ($flink) {
|
if (!empty($flink)) {
|
||||||
$user = $flink->getUser();
|
$user = $flink->getUser();
|
||||||
|
|
||||||
if (!empty($user)) {
|
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_set_user($user);
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
@ -342,7 +353,8 @@ class FBConnectauthAction extends Action
|
|||||||
|
|
||||||
} else {
|
} 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());
|
$this->showForm(null, $this->bestNewNickname());
|
||||||
}
|
}
|
||||||
@ -438,7 +450,8 @@ class FBConnectauthAction extends Action
|
|||||||
return reset($infos);
|
return reset($infos);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} 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 .
|
join(",", $fields) . " on uid " . $fb_uid .
|
||||||
" : ". $e->getMessage());
|
" : ". $e->getMessage());
|
||||||
return null;
|
return null;
|
||||||
|
@ -214,7 +214,7 @@ class FBConnectPlugin extends Plugin
|
|||||||
$fbuid = $facebook->get_loggedin_user();
|
$fbuid = $facebook->get_loggedin_user();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_WARNING,
|
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
|
||||||
'Problem getting Facebook user: ' .
|
'Problem getting Facebook user: ' .
|
||||||
$e->getMessage());
|
$e->getMessage());
|
||||||
}
|
}
|
||||||
@ -351,7 +351,8 @@ class FBConnectPlugin extends Plugin
|
|||||||
$facebook = getFacebook();
|
$facebook = getFacebook();
|
||||||
$facebook->expire_session();
|
$facebook->expire_session();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_WARNING, 'Could\'t logout of Facebook: ' .
|
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
|
||||||
|
'Could\'t logout of Facebook: ' .
|
||||||
$e->getMessage());
|
$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +377,8 @@ class FBConnectPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} 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;
|
return $url;
|
||||||
|
@ -186,7 +186,7 @@ class FBConnectSettingsAction extends ConnectSettingsAction
|
|||||||
$facebook->clear_cookie_state();
|
$facebook->clear_cookie_state();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_WARNING,
|
common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
|
||||||
'Couldn\'t clear Facebook cookies: ' .
|
'Couldn\'t clear Facebook cookies: ' .
|
||||||
$e->getMessage());
|
$e->getMessage());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user