コード例 #1
0
ファイル: oauth.php プロジェクト: ratbird/hope
 /**
  *
  **/
 public function authorize_action()
 {
     global $user, $auth;
     $auth_plugin = Config::get()->API_OAUTH_AUTH_PLUGIN;
     if ($GLOBALS['user']->id === 'nobody' && $auth_plugin !== 'Standard' && !Request::option('sso')) {
         $params = $_GET;
         $params['sso'] = $auth_plugin;
         $this->redirect($this->url_for('api/oauth/authorize?' . http_build_query($params)));
         return;
     } else {
         $auth->login_if($user->id === 'nobody');
     }
     $user_id = RESTAPI\Consumer\OAuth::getOAuthId($GLOBALS['user']->id);
     try {
         $consumer = RESTAPI\Consumer\Base::detectConsumer('oauth', 'request');
         if (Request::submitted('allow')) {
             $result = $consumer->grantAccess($GLOBALS['user']->id);
             $redirect_uri = Request::get('oauth_callback', $consumer->callback);
             if ($redirect_uri) {
                 $this->redirect($redirect_uri);
             } else {
                 // No oauth_callback, show the user the result of the authorization
                 // ** your code here **
                 PageLayout::postMessage(MessageBox::success(_('Sie haben der Applikation Zugriff auf Ihre Daten gewährt.')));
                 $this->redirect('api/authorizations#' . $consumer->auth_key);
             }
             return;
         }
     } catch (OAuthException $e) {
         // No token to be verified in the request, show a page where the user can enter the token to be verified
         // **your code here**
         die('invalid');
     }
     PageLayout::disableHeader();
     PageLayout::setTitle(sprintf(_('"%s" bittet um Zugriff'), $consumer->title));
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base.php'));
     $this->consumer = $consumer;
     $this->token = Request::option('oauth_token');
     $this->oauth_callback = Request::get('oauth_callback');
 }
コード例 #2
0
ファイル: authorizations.php プロジェクト: ratbird/hope
 /**
  *
  **/
 public function revoke_action($id)
 {
     RESTAPI\Consumer\Base::find($id)->revokeAccess($GLOBALS['user']->id);
     PageLayout::postMessage(MessageBox::success(_('Der Applikation wurde der Zugriff auf Ihre Daten untersagt.')));
     $this->redirect('api/authorizations');
 }
コード例 #3
0
ファイル: api.php プロジェクト: ratbird/hope
 /**
  *
  **/
 public function toggle_action($id, $state = null)
 {
     $consumer = RESTAPI\Consumer\Base::find($id);
     $consumer->active = $state === null ? !$consumer->active : $state === 'on';
     $consumer->store();
     $message = $state ? _('Die Applikation wurde erfolgreich aktiviert.') : _('Die Applikation wurde erfolgreich deaktiviert.');
     PageLayout::postMessage(MessageBox::success($message));
     $this->redirect('admin/api/#' . $consumer->id);
 }