3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010-2011, StatusNet, Inc.
6 * An action that handles deauthorize callbacks from Facebook
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Zach Copley <zach@status.net>
26 * @copyright 2010-2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
36 * Action class for handling deauthorize callbacks from Facebook. If the user
37 * doesn't have a password let her know she'll need to contact the site
38 * admin to get back into her account (if possible).
40 class FacebookdeauthorizeAction extends Action
45 * For initializing members of the class.
47 * @param array $args misc. arguments
49 * @return boolean true
51 function prepare($args)
53 $this->facebook = Facebookclient::getFacebook();
61 * @param array $args is ignored since it's now passed in in prepare()
63 function handle($args)
65 parent::handle($args);
67 $data = $this->facebook->getSignedRequest();
69 if (isset($data['user_id'])) {
71 $fbuid = $data['user_id'];
73 $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
74 $user = $flink->getUser();
76 // Remove the link to Facebook
77 $result = $flink->delete();
80 common_log_db_error($flink, 'DELETE', __FILE__);
84 'Unable to delete Facebook foreign link '
85 . 'for %s (%d), fbuid %d',
98 'Facebook callback: %s (%d), fbuid %d has deauthorized '
99 . 'the Facebook application.',
107 // Warn the user about being locked out of their account
109 if (empty($user->password) && !empty($user->email)) {
110 Facebookclient::emailWarn($user);
115 '%s (%d), fbuid %d has deauthorized his/her Facebook '
116 . 'connection but hasn\'t set a password so s/he '
131 'Facebook called the deauthorize callback '
132 . ' but didn\'t provide a user ID.'
137 // It probably wasn't Facebook that hit this action,
138 // so redirect to the public timeline
139 common_redirect(common_local_url('public'), 303);