X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FFacebookBridge%2Factions%2Ffacebookfinishlogin.php;h=4a9e09b53dfe1c27fe1f9a0ce2b7987c8d0e8a98;hb=e2d85a39e7f82ceef2cb2fe66a3a9a62ac9a363e;hp=ab83601ce1e976089bbbb26a114888add976f494;hpb=acbe94936f6d9edf24781550e2eabef24d13c455;p=quix0rs-gnu-social.git diff --git a/plugins/FacebookBridge/actions/facebookfinishlogin.php b/plugins/FacebookBridge/actions/facebookfinishlogin.php index ab83601ce1..4a9e09b53d 100644 --- a/plugins/FacebookBridge/actions/facebookfinishlogin.php +++ b/plugins/FacebookBridge/actions/facebookfinishlogin.php @@ -37,7 +37,7 @@ class FacebookfinishloginAction extends Action private $fbuser = null; // Facebook user object (JSON) private $accessToken = null; // Access token provided by Facebook JS API - function prepare($args) { + function prepare(array $args=array()) { parent::prepare($args); // Check cookie for a valid access_token @@ -48,7 +48,6 @@ class FacebookfinishloginAction extends Action if (empty($this->accessToken)) { $this->clientError(_m("Unable to authenticate you with Facebook.")); - return false; } $graphUrl = 'https://graph.facebook.com/me?access_token=' . urlencode($this->accessToken); @@ -80,7 +79,7 @@ class FacebookfinishloginAction extends Action return true; } - function handle($args) + function handle(array $args=array()) { parent::handle($args); @@ -117,8 +116,6 @@ class FacebookfinishloginAction extends Action // TRANS: in the same StatusNet site. _m('There is already a local account linked with that Facebook account.') ); - - return; } $cur = common_current_user(); @@ -133,8 +130,6 @@ class FacebookfinishloginAction extends Action // TRANS: in the same StatusNet site. _m('There is already a local account linked with that Facebook account.') ); - - return; } } @@ -329,7 +324,6 @@ class FacebookfinishloginAction extends Action if (common_config('site', 'closed')) { // TRANS: Client error trying to register with registrations not allowed. $this->clientError(_m('Registration not allowed.')); - return; } $invite = null; @@ -339,7 +333,6 @@ class FacebookfinishloginAction extends Action if (empty($code)) { // TRANS: Client error trying to register with registrations 'invite only'. $this->clientError(_m('Registration not allowed.')); - return; } $invite = Invitation::getKV($code); @@ -347,7 +340,6 @@ class FacebookfinishloginAction extends Action if (empty($invite)) { // TRANS: Client error trying to register with an invalid invitation code. $this->clientError(_m('Not a valid invitation code.')); - return; } } @@ -384,7 +376,6 @@ class FacebookfinishloginAction extends Action if (!$result) { // TRANS: Server error displayed when connecting to Facebook fails. $this->serverError(_m('Error connecting user to Facebook.')); - return; } // Add a Foreign_user record @@ -445,8 +436,14 @@ class FacebookfinishloginAction extends Action } else { // save it as an avatar - $file = new ImageFile($user->id, Avatar::path($tmpname)); - $filename = $file->resize(180); // size of the biggest img we get from Facebook + $imagefile = new ImageFile(null, Avatar::path($tmpname)); + $filename = Avatar::filename($user->id, image_type_to_extension($imagefile->preferredType()), + 180, common_timestamp()); + // Previous docs said 180 is the "biggest img we get from Facebook" + $imagefile->resizeTo(Avatar::path($filename, array('width'=>180, 'height'=>180))); + + // No need to keep the temporary file around... + @unlink(Avatar::path($tmpname)); $profile = $user->getProfile(); @@ -466,7 +463,6 @@ class FacebookfinishloginAction extends Action ); // clean up tmp file - @unlink(Avatar::path($tmpname)); } } @@ -518,40 +514,35 @@ class FacebookfinishloginAction extends Action if (empty($result)) { // TRANS: Server error displayed when connecting to Facebook fails. $this->serverError(_m('Error connecting user to Facebook.')); - return; } } function tryLogin() { - $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE); - - if (!empty($flink)) { + try { + $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE); $user = $flink->getUser(); - if (!empty($user)) { - - common_log( - LOG_INFO, - sprintf( - 'Logged in Facebook user %s as user %d (%s)', - $this->fbuid, - $user->nickname, - $user->id - ), - __FILE__ - ); + common_log( + LOG_INFO, + sprintf( + 'Logged in Facebook user %s as user %d (%s)', + $this->fbuid, + $user->nickname, + $user->id + ), + __FILE__ + ); - common_set_user($user); - common_real_login(true); + common_set_user($user); + common_real_login(true); - // clear out the stupid cookie - setcookie('fb_access_token', '', time() - 3600); // one hour ago + // clear out the stupid cookie + setcookie('fb_access_token', '', time() - 3600); // one hour ago - $this->goHome($user->nickname); - } + $this->goHome($user->nickname); - } else { + } catch (NoResultException $e) { $this->showForm(null, $this->bestNewNickname()); } }