コード例 #1
0
ファイル: openidsettings.php プロジェクト: Grasia/bolotweet
 /**
  * Handles a request to remove OpenID trustroots from the user's account
  *
  * Validates input and, if everything is OK, deletes the trustroots.
  * Reloads the form with a success or error notification.
  *
  * @return void
  */
 function removeTrustroots()
 {
     $user = common_current_user();
     $trustroots = $this->arg('openid_trustroot');
     if ($trustroots) {
         foreach ($trustroots as $trustroot) {
             $user_openid_trustroot = User_openid_trustroot::pkeyGet(array('user_id' => $user->id, 'trustroot' => $trustroot));
             if ($user_openid_trustroot) {
                 $user_openid_trustroot->delete();
             } else {
                 // TRANS: Form validation error when trying to remove a non-existing trustroot.
                 $this->showForm(_m('No such OpenID trustroot.'));
                 return;
             }
         }
         // TRANS: Success message after removing trustroots.
         $this->showForm(_m('Trustroots removed.'), true);
     } else {
         $this->showForm();
     }
     return;
 }
コード例 #2
0
ファイル: openidserver.php プロジェクト: Grasia/bolotweet
 function handle($args)
 {
     parent::handle($args);
     $request = $this->oserver->decodeRequest();
     if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) {
         $user = common_current_user();
         if (!$user) {
             if ($request->immediate) {
                 //cannot prompt the user to login in immediate mode, so answer false
                 $response = $this->generateDenyResponse($request);
             } else {
                 // Go log in, and then come back.
                 //
                 // Note: 303 redirect rather than 307 to avoid
                 // prompting user for form resubmission if we
                 // were POSTed here.
                 common_set_returnto($_SERVER['REQUEST_URI']);
                 common_redirect(common_local_url('login'), 303);
                 return;
             }
         } else {
             if (common_profile_url($user->nickname) == $request->identity || $request->idSelect()) {
                 $user_openid_trustroot = User_openid_trustroot::pkeyGet(array('user_id' => $user->id, 'trustroot' => $request->trust_root));
                 if (empty($user_openid_trustroot)) {
                     if ($request->immediate) {
                         //cannot prompt the user to trust this trust root in immediate mode, so answer false
                         $response = $this->generateDenyResponse($request);
                     } else {
                         common_ensure_session();
                         $_SESSION['openid_trust_root'] = $request->trust_root;
                         $allowResponse = $this->generateAllowResponse($request, $user);
                         $this->oserver->encodeResponse($allowResponse);
                         //sign the response
                         $denyResponse = $this->generateDenyResponse($request);
                         $this->oserver->encodeResponse($denyResponse);
                         //sign the response
                         $_SESSION['openid_allow_url'] = $allowResponse->encodeToUrl();
                         $_SESSION['openid_deny_url'] = $denyResponse->encodeToUrl();
                         // Ask the user to trust this trust root...
                         //
                         // Note: 303 redirect rather than 307 to avoid
                         // prompting user for form resubmission if we
                         // were POSTed here.
                         common_redirect(common_local_url('openidtrust'), 303);
                         return;
                     }
                 } else {
                     //user has previously authorized this trust root
                     $response = $this->generateAllowResponse($request, $user);
                     //$response = $request->answer(true, null, common_profile_url($user->nickname));
                 }
             } else {
                 if ($request->immediate) {
                     $response = $this->generateDenyResponse($request);
                 } else {
                     //invalid
                     // TRANS: OpenID plugin client error given trying to add an unauthorised OpenID to a user (403).
                     // TRANS: %s is a request identity.
                     $this->clientError(sprintf(_m('You are not authorized to use the identity %s.'), $request->identity), $code = 403);
                 }
             }
         }
     } else {
         $response = $this->oserver->handleRequest($request);
     }
     if ($response) {
         $response = $this->oserver->encodeResponse($response);
         if ($response->code != AUTH_OPENID_HTTP_OK) {
             header(sprintf("HTTP/1.1 %d ", $response->code), true, $response->code);
         }
         if ($response->headers) {
             foreach ($response->headers as $k => $v) {
                 header("{$k}: {$v}");
             }
         }
         $this->raw($response->body);
     } else {
         // TRANS: OpenID plugin client error given when not getting a response for a given OpenID provider (500).
         $this->clientError(_m('Just an OpenID provider. Nothing to see here, move along...'), $code = 500);
     }
 }
コード例 #3
0
ファイル: openidsettings.php プロジェクト: Br3nda/StatusNet
 /**
  * Handles a request to remove OpenID trustroots from the user's account
  *
  * Validates input and, if everything is OK, deletes the trustroots.
  * Reloads the form with a success or error notification.
  *
  * @return void
  */
 function removeTrustroots()
 {
     $user = common_current_user();
     $trustroots = $this->arg('openid_trustroot');
     if ($trustroots) {
         foreach ($trustroots as $trustroot) {
             $user_openid_trustroot = User_openid_trustroot::pkeyGet(array('user_id' => $user->id, 'trustroot' => $trustroot));
             if ($user_openid_trustroot) {
                 $user_openid_trustroot->delete();
             } else {
                 $this->showForm(_m('No such OpenID trustroot.'));
                 return;
             }
         }
         $this->showForm(_m('Trustroots removed'), true);
     } else {
         $this->showForm();
     }
     return;
 }
コード例 #4
0
 /**
  * Handles a request to remove OpenID trustroots from the user's account
  *
  * Validates input and, if everything is OK, deletes the trustroots.
  * Reloads the form with a success or error notification.
  *
  * @return void
  */
 function removeTrustroots()
 {
     $trustroots = $this->arg('openid_trustroot', array());
     foreach ($trustroots as $trustroot) {
         $user_openid_trustroot = User_openid_trustroot::pkeyGet(array('user_id' => $this->scoped->getID(), 'trustroot' => $trustroot));
         if ($user_openid_trustroot) {
             $user_openid_trustroot->delete();
         } else {
             // TRANS: Form validation error when trying to remove a non-existing trustroot.
             throw new ClientException(_m('No such OpenID trustroot.'));
         }
     }
     // TRANS: Success message after removing trustroots.
     return _m('Trustroots removed.');
 }