123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class FacebookdeauthorizeAction extends Action
- {
- private $facebook;
-
- function prepare($args)
- {
- $this->facebook = Facebookclient::getFacebook();
- return true;
- }
-
- function handle($args)
- {
- parent::handle($args);
- $data = $this->facebook->getSignedRequest();
- if (isset($data['user_id'])) {
- $fbuid = $data['user_id'];
- $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
- $user = $flink->getUser();
-
- $result = $flink->delete();
- if (!$result) {
- common_log_db_error($flink, 'DELETE', __FILE__);
- common_log(
- LOG_WARNING,
- sprintf(
- 'Unable to delete Facebook foreign link '
- . 'for %s (%d), fbuid %d',
- $user->nickname,
- $user->id,
- $fbuid
- ),
- __FILE__
- );
- return;
- }
- common_log(
- LOG_INFO,
- sprintf(
- 'Facebook callback: %s (%d), fbuid %d has deauthorized '
- . 'the Facebook application.',
- $user->nickname,
- $user->id,
- $fbuid
- ),
- __FILE__
- );
-
-
- if (empty($user->password) && !empty($user->email)) {
- Facebookclient::emailWarn($user);
- } else {
- common_log(
- LOG_WARNING,
- sprintf(
- '%s (%d), fbuid %d has deauthorized his/her Facebook '
- . 'connection but hasn\'t set a password so s/he '
- . 'is locked out.',
- $user->nickname,
- $user->id,
- $fbuid
- ),
- __FILE__
- );
- }
- } else {
- if (!empty($data)) {
- common_log(
- LOG_WARNING,
- sprintf(
- 'Facebook called the deauthorize callback '
- . ' but didn\'t provide a user ID.'
- ),
- __FILE__
- );
- } else {
-
-
- common_redirect(common_local_url('public'), 303);
- }
- }
- }
- }
|