Example #1
0
 /**
  * Class handler
  *
  * @param array $args query arguments
  *
  * @return nothing
  *
  **/
 function handle($args)
 {
     parent::handle($args);
     try {
         $srv = new OMB_Service_Provider(null, omb_oauth_datastore(), omb_oauth_server());
         $srv->writeAccessToken();
     } catch (Exception $e) {
         $this->serverError($e->getMessage());
     }
 }
Example #2
0
 function handle($args)
 {
     parent::handle($args);
     try {
         $srv = new OMB_Service_Provider(null, omb_oauth_datastore(), omb_oauth_server());
         $srv->handleUpdateProfile();
     } catch (OMB_RemoteServiceException $rse) {
         $msg = $rse->getMessage();
         if (preg_match('/Revoked accesstoken/', $msg) || preg_match('/No subscriber/', $msg)) {
             $this->clientError($msg, 403);
         } else {
             $this->clientError($msg);
         }
     } catch (Exception $e) {
         $this->serverError($e->getMessage());
         return;
     }
 }
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         /* Use a session token for CSRF protection. */
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
             $srv = $this->getStoredParams();
             // TRANS: Client error displayed when the session token does not match or is not given.
             $this->showForm($srv->getRemoteUser(), _('There was a problem ' . 'with your session token. Try again, ' . 'please.'));
             return;
         }
         /* We've shown the form, now post user's choice. */
         $this->sendAuthorization();
     } else {
         if (!common_logged_in()) {
             /* Go log in, and then come back. */
             common_set_returnto($_SERVER['REQUEST_URI']);
             common_redirect(common_local_url('login'));
             return;
         }
         $user = common_current_user();
         $profile = $user->getProfile();
         if (!$profile) {
             common_log_db_error($user, 'SELECT', __FILE__);
             // TRANS: Error message displayed when referring to a user without a profile.
             $this->serverError(_('User has no profile.'));
             return;
         }
         /* TODO: If no token is passed the user should get a prompt to enter
            it according to OAuth Core 1.0. */
         try {
             $this->validateOmb();
             $srv = new OMB_Service_Provider(profile_to_omb_profile($user->uri, $profile), omb_oauth_datastore());
             $remote_user = $srv->handleUserAuth();
         } catch (Exception $e) {
             $this->clearParams();
             $this->clientError($e->getMessage());
             return;
         }
         $this->storeParams($srv);
         $this->showForm($remote_user);
     }
 }