From 54cd0a2046c417fd072bb4cf79aeda163cf760af Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 21 May 2009 05:43:11 +0000 Subject: - Reworked login / logout workflow - Added Facebook Connect tab to login nav - Show Facebook mini-avatar when logged in - Added Facebook Connect tab to connect settings nav - Option to disconnect from Facebook --- plugins/FBConnect/FBConnectAuth.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'plugins/FBConnect/FBConnectAuth.php') diff --git a/plugins/FBConnect/FBConnectAuth.php b/plugins/FBConnect/FBConnectAuth.php index 0dc016c05..e8724cdf9 100644 --- a/plugins/FBConnect/FBConnectAuth.php +++ b/plugins/FBConnect/FBConnectAuth.php @@ -29,7 +29,7 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php'; -class FbconnectauthAction extends Action +class FBConnectauthAction extends Action { var $fbuid = null; @@ -38,9 +38,20 @@ class FbconnectauthAction extends Action function prepare($args) { parent::prepare($args); - $this->fbuid = getFacebook()->get_loggedin_user(); - $this->fb_fields = $this->getFacebookFields($this->fbuid, - array('first_name', 'last_name', 'name')); + try { + + $this->fbuid = getFacebook()->get_loggedin_user(); + + if ($this->fbuid > 0) { + $this->fb_fields = $this->getFacebookFields($this->fbuid, + array('first_name', 'last_name', 'name')); + } else { + common_debug("No Facebook User found."); + } + + } catch (Exception $e) { + common_debug("Problem getting fbuid."); + } return true; } @@ -52,6 +63,7 @@ class FbconnectauthAction extends Action if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_('There was a problem with your session token. Try again, please.')); @@ -113,7 +125,7 @@ class FbconnectauthAction extends Action $this->elementStart('form', array('method' => 'post', 'id' => 'account_connect', - 'action' => common_local_url('fbconnectlogin'))); + 'action' => common_local_url('FBConnectAuth'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Create new account')); @@ -255,7 +267,7 @@ class FbconnectauthAction extends Action { common_debug("Trying Facebook Login..."); - $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE); + $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_CONNECT_SERVICE); if ($flink) { $user = $flink->getUser(); @@ -270,6 +282,9 @@ class FbconnectauthAction extends Action } } else { + + common_debug("no flink found for fbuid: $this->fbuid"); + $this->showForm(null, $this->bestNewNickname()); } } @@ -291,10 +306,12 @@ class FbconnectauthAction extends Action function flinkUser($user_id, $fbuid) { + common_debug("flinkUser()"); + $flink = new Foreign_link(); $flink->user_id = $user_id; $flink->foreign_id = $fbuid; - $flink->service = FACEBOOK_SERVICE; + $flink->service = FACEBOOK_CONNECT_SERVICE; $flink->created = common_sql_now(); $flink_id = $flink->insert(); -- cgit v1.2.3-54-g00ecf