コード例 #1
0
ファイル: SupportForm.php プロジェクト: digideskio/dsp-core
 /**
  * @param array $attributes
  * @param bool  $clearErrors
  *
  * @throws DreamFactory\Platform\Exceptions\ForbiddenException
  * @return bool
  */
 public function validate($attributes = null, $clearErrors = true)
 {
     if ($this->_skipped) {
         $this->_emailAddress = null;
         return true;
     }
     /** @var User $_user */
     if (null === ($_user = User::model()->findByPk(Session::getCurrentUserId()))) {
         throw new ForbiddenException();
     }
     if (empty($this->_emailAddress)) {
         $this->_emailAddress = $_user->email;
     }
     return parent::validate($attributes, $clearErrors);
 }
コード例 #2
0
ファイル: WebController.php プロジェクト: rascyber/dsp-core
 /**
  * Action for URL that the client redirects to when coming back from providers.
  */
 public function actionRemoteLogin()
 {
     if (null !== $this->_remoteError) {
         $this->_redirectError($this->_remoteError);
     }
     if (null === ($_providerId = Option::request('pid'))) {
         throw new BadRequestException('No remote login provider specified.');
     }
     $this->layout = false;
     $_flow = FilterInput::request('flow', Flows::CLIENT_SIDE, FILTER_SANITIZE_NUMBER_INT);
     //	Check local then global...
     if (null === ($_providerModel = Provider::model()->byPortal($_providerId)->find())) {
         /** @var \stdClass $_providerModel */
         $_providerModel = Fabric::getProviderCredentials($_providerId);
         if (empty($_providerModel)) {
             throw new BadRequestException('The provider "' . $_providerId . '" is not available.');
         }
         //  Translate from back-end to front-end
         $_model = new stdClass();
         $_model->id = $_providerModel->id;
         $_model->provider_name = $_providerModel->provider_name_text;
         $_model->config_text = $_providerModel->config_text;
         $_model->api_name = $_providerModel->endpoint_text;
         $_model->is_active = $_providerModel->enable_ind;
         $_model->is_login_provider = $_providerModel->login_provider_ind;
         $_providerModel = $_model;
     }
     //	Set our store...
     Oasys::setStore($_store = new ProviderUserStore(Session::getCurrentUserId(), $_providerModel->id));
     $_config = Provider::buildConfig($_providerModel, Pii::getState($_providerId . '.user_config', array()), array('flow_type' => $_flow, 'redirect_uri' => Curl::currentUrl(false) . '?pid=' . $_providerModel->provider_name));
     $_provider = Oasys::getProvider($_providerId, $_config);
     if ($_provider->handleRequest()) {
         //	Now let the user model figure out what to do...
         try {
             $_user = User::remoteLoginRequest($_providerId, $_provider, $_providerModel);
             Log::debug('Remote login success: ' . $_user->email . ' (id#' . $_user->id . ')');
         } catch (\Exception $_ex) {
             Log::error($_ex->getMessage());
             //	No soup for you!
             $this->_redirectError($_ex->getMessage());
         }
         //	Go home baby!
         $this->redirect('/');
     }
     Log::error('Seems that the provider rejected the login...');
     $this->_redirectError('Error during remote login sequence. Please try again.');
 }