コード例 #1
0
 /**
  * @return string
  */
 public function ServiceSso()
 {
     $oException = null;
     $oAccount = null;
     $bLogout = true;
     $sSsoHash = $this->oHttp->GetRequest('hash', '');
     if (!empty($sSsoHash)) {
         $mData = null;
         $sSsoSubData = $this->Cacher()->Get(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash));
         if (!empty($sSsoSubData)) {
             $mData = \RainLoop\Utils::DecodeKeyValuesQ($sSsoSubData);
             $this->Cacher()->Delete(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash));
             if (\is_array($mData) && !empty($mData['Email']) && isset($mData['Password'], $mData['Time']) && (0 === $mData['Time'] || \time() - 10 < $mData['Time'])) {
                 $sEmail = \trim($mData['Email']);
                 $sPassword = $mData['Password'];
                 $aAdditionalOptions = isset($mData['AdditionalOptions']) && \is_array($mData['AdditionalOptions']) && 0 < \count($mData['AdditionalOptions']) ? $mData['AdditionalOptions'] : null;
                 try {
                     $oAccount = $this->oActions->LoginProcess($sEmail, $sPassword);
                     if ($oAccount instanceof \RainLoop\Model\Account && $aAdditionalOptions) {
                         $bNeedToSettings = false;
                         $oSettings = $this->SettingsProvider()->Load($oAccount);
                         if ($oSettings) {
                             $sLanguage = isset($aAdditionalOptions['Language']) ? $aAdditionalOptions['Language'] : '';
                             if ($sLanguage) {
                                 $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
                                 if ($sLanguage !== $oSettings->GetConf('Language', '')) {
                                     $bNeedToSettings = true;
                                     $oSettings->SetConf('Language', $sLanguage);
                                 }
                             }
                         }
                         if ($bNeedToSettings) {
                             $this->SettingsProvider()->Save($oAccount, $oSettings);
                         }
                     }
                     $this->oActions->AuthToken($oAccount);
                     $bLogout = !$oAccount instanceof \RainLoop\Model\Account;
                 } catch (\Exception $oException) {
                     $this->oActions->Logger()->WriteException($oException);
                 }
             }
         }
     }
     if ($bLogout) {
         $this->oActions->SetAuthLogoutToken();
     }
     $this->oActions->Location('./');
     return '';
 }
コード例 #2
0
 /**
  * @param string $sRawKey
  *
  * @return array | false
  */
 private function getDecodedRawKeyValue($sRawKey)
 {
     $bResult = false;
     if (!empty($sRawKey)) {
         $aValues = \RainLoop\Utils::DecodeKeyValuesQ($sRawKey);
         if (is_array($aValues)) {
             $bResult = $aValues;
         }
     }
     return $bResult;
 }