Ejemplo n.º 1
0
 /**
  * @return string
  */
 public function ServiceExternalSso()
 {
     $sResult = '';
     $bLogout = true;
     $sKey = $this->oActions->Config()->Get('labs', 'external_sso_key', '');
     if ($this->oActions->Config()->Get('labs', 'allow_external_sso', false) && !empty($sKey) && $sKey === \trim($this->oHttp->GetRequest('SsoKey', ''))) {
         $sEmail = \trim($this->oHttp->GetRequest('Email', ''));
         $sPassword = $this->oHttp->GetRequest('Password', '');
         $sResult = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
         $bLogout = 0 === \strlen($sResult);
         switch (\strtolower($this->oHttp->GetRequest('Output', 'Plain'))) {
             case 'plain':
                 @\header('Content-Type: text/plain');
                 break;
             case 'json':
                 @\header('Content-Type: application/json; charset=utf-8');
                 $sResult = \MailSo\Base\Utils::Php2js(array('Action' => 'ExternalSso', 'Result' => $sResult), $this->Logger());
                 break;
         }
     }
     if ($bLogout) {
         $this->oActions->SetAuthLogoutToken();
     }
     return $sResult;
 }