/**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->format = $this->arg('format');
     $this->url = $this->arg('url');
     return true;
 }
Beispiel #2
0
 /**
  * Take arguments for running, looks for an OAuth request,
  * and outputs basic auth header if needed
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 function prepare($args)
 {
     parent::prepare($args);
     // NOTE: $this->auth_user has to get set in prepare(), not handle(),
     // because subclasses do stuff with it in their prepares.
     $oauthReq = $this->getOAuthRequest();
     if (!$oauthReq) {
         if ($this->requiresAuth()) {
             $this->checkBasicAuthUser(true);
         } else {
             // Check to see if a basic auth user is there even
             // if one's not required
             $this->checkBasicAuthUser(false);
         }
     } else {
         $this->checkOAuthRequest($oauthReq);
     }
     // Reject API calls with the wrong access level
     if ($this->isReadOnly($args) == false) {
         if ($this->access != self::READ_WRITE) {
             // TRANS: Client error 401.
             $msg = _('API resource requires read-write access, ' . 'but you only have read access.');
             $this->clientError($msg, 401, $this->format);
             exit;
         }
     }
     return true;
 }
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     if ($this->format !== 'json') {
         $this->clientError('This method currently only serves JSON.', 415);
     }
     $this->code = $this->trimmed('code');
     return true;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     if (common_config('site', 'private')) {
         $this->clientError(_('This site is private.'), 403);
     }
     if ($this->format !== 'json') {
         $this->clientError('This method currently only serves JSON.', 415);
     }
     return true;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->email = $this->trimmed('email');
     if (!Validate::email($this->email, common_config('email', 'check_domain'))) {
         $this->clientError('Not a valid email address.', 400);
     }
     if (common_config('site', 'private')) {
         $this->clientError(_('This site is private.'), 403);
     }
     return true;
 }
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->nickname = Nickname::normalize($this->arg('nickname'));
     $this->email = $this->arg('email');
     $this->fullname = $this->arg('fullname');
     $this->homepage = $this->arg('homepage');
     $this->bio = $this->arg('bio');
     $this->location = $this->arg('location');
     // We don't trim these... whitespace is OK in a password!
     $this->password = $this->arg('password');
     $this->confirm = $this->arg('confirm');
     return true;
 }
Beispiel #7
0
 /**
  * Take arguments for running, looks for an OAuth request,
  * and outputs basic auth header if needed
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     // NOTE: $this->auth_user has to get set in prepare(), not handle(),
     // because subclasses do stuff with it in their prepares.
     // qvitterfix, accepts regular login session
     if (common_logged_in()) {
         $this->scoped = Profile::current();
         $this->auth_user = $this->scoped->getUser();
         if (!$this->auth_user->hasRight(Right::API)) {
             // TRANS: Authorization exception thrown when a user without API access tries to access the API.
             throw new AuthorizationException(_('Not allowed to use API.'));
         }
         $this->access = self::READ_WRITE;
         Event::handle('EndSetApiUser', array($this->auth_user));
     } else {
         $oauthReq = $this->getOAuthRequest();
         if (!$oauthReq) {
             if ($this->requiresAuth()) {
                 $this->checkBasicAuthUser(true);
             } else {
                 // Check to see if a basic auth user is there even
                 // if one's not required
                 $this->checkBasicAuthUser(false);
             }
         } else {
             $this->checkOAuthRequest($oauthReq);
         }
     }
     // NOTE: Make sure we're scoped properly based on the auths!
     if (isset($this->auth_user) && !empty($this->auth_user)) {
         $this->scoped = $this->auth_user->getProfile();
     } else {
         $this->scoped = null;
     }
     // legacy user transferral
     // TODO: remove when sure no extended classes need it
     $this->user = $this->auth_user;
     // Reject API calls with the wrong access level
     if ($this->isReadOnly($args) == false) {
         if ($this->access != self::READ_WRITE) {
             // TRANS: Client error 401.
             $msg = _('API resource requires read-write access, ' . 'but you only have read access.');
             $this->clientError($msg, 401);
         }
     }
     return true;
 }
Beispiel #8
0
 /**
  * Take arguments for running, looks for an OAuth request,
  * and outputs basic auth header if needed
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     // NOTE: $this->scoped and $this->auth_user has to get set in
     // prepare(), not handle(), as subclasses use them in prepares.
     // Allow regular login session
     if (common_logged_in()) {
         $this->scoped = Profile::current();
         $this->auth_user = $this->scoped->getUser();
         if (!$this->auth_user->hasRight(Right::API)) {
             // TRANS: Authorization exception thrown when a user without API access tries to access the API.
             throw new AuthorizationException(_('Not allowed to use API.'));
         }
         // Let's run this in the same way as if we've just authenticated the user (basic/oauth auth)
         Event::handle('EndSetApiUser', array($this->auth_user));
         $this->access = self::READ_WRITE;
     } else {
         $oauthReq = $this->getOAuthRequest();
         if ($oauthReq instanceof OAuthRequest) {
             $this->checkOAuthRequest($oauthReq);
         } else {
             // If not using OAuth, check if there is a basic auth
             // and require it if the current action requires it.
             $this->checkBasicAuthUser($this->requiresAuth());
         }
         // NOTE: Make sure we're scoped properly based on the auths!
         if (isset($this->auth_user) && $this->auth_user instanceof User) {
             $this->scoped = $this->auth_user->getProfile();
         } else {
             $this->scoped = null;
         }
     }
     // legacy user transferral
     // TODO: remove when sure no extended classes need it
     $this->user = $this->auth_user;
     // Reject API calls with the wrong access level
     if ($this->isReadOnly($args) == false) {
         if ($this->access != self::READ_WRITE) {
             // TRANS: Client error 401.
             $msg = _('API resource requires read-write access, ' . 'but you only have read access.');
             $this->clientError($msg, 401);
         }
     }
     return true;
 }
Beispiel #9
0
 /**
  * Initialization.
  *
  * @param array $args Web and URL arguments
  *
  * @return boolean true if nothing goes wrong
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->query = $this->trimmed('q');
     $this->lang = $this->trimmed('lang');
     $this->rpp = $this->trimmed('rpp');
     if (!$this->rpp) {
         $this->rpp = 15;
     }
     if ($this->rpp > 100) {
         $this->rpp = 100;
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     $this->since_id = $this->trimmed('since_id');
     $this->geocode = $this->trimmed('geocode');
     return true;
 }
 function prepare($args)
 {
     parent::prepare($args);
     return true;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $user = common_current_user();
     return true;
 }
 function prepare($args)
 {
     parent::prepare($args);
     $this->token = $this->trimmed('token');
     return true;
 }
Beispiel #13
0
 /**
  * Read arguments and initialize members
  *
  * @param array $args Arguments from $_REQUEST
  *
  * @return boolean success
  *
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->query = $this->trimmed('q');
     $this->lang = $this->trimmed('lang');
     $this->rpp = $this->trimmed('rpp');
     if (!$this->rpp) {
         $this->rpp = 15;
     }
     if ($this->rpp > 100) {
         $this->rpp = 100;
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     // TODO: Suppport since_id -- we need to tweak the backend
     // Search classes to support it.
     $this->since_id = $this->trimmed('since_id');
     $this->geocode = $this->trimmed('geocode');
     // TODO: Also, language and geocode
     return true;
 }
 protected function prepare(array $args = array())
 {
     self::cleanRequest();
     return parent::prepare($args);
 }