Sso integration, Simple Rainloop Api (#103)

Small fixes
This commit is contained in:
RainLoop Team 2014-04-14 20:07:33 +04:00
parent dde42c6190
commit e211899c7b
12 changed files with 191 additions and 18 deletions

View file

@ -1077,6 +1077,10 @@ RainLoopApp.prototype.bootstart = function ()
RL.quota();
});
RL.sub('interval.10m', function () {
RL.folders();
});
_.delay(function () {
RL.folderInformationMultiply(true);
}, 500);

View file

@ -12,6 +12,7 @@ function PopupsComposeViewModel()
this.aDraftInfo = null;
this.sInReplyTo = '';
this.bFromDraft = false;
this.bSkipNext = false;
this.sReferences = '';
this.bAllowIdentities = RL.settingsGet('AllowIdentities');
@ -278,6 +279,8 @@ function PopupsComposeViewModel()
this.savedError(false);
this.saving(true);
this.bSkipNext = true;
RL.cache().setFolderHash(RL.data().draftFolder(), '');
RL.remote().saveMessage(
@ -303,8 +306,9 @@ function PopupsComposeViewModel()
RL.sub('interval.1m', function () {
if (this.modalVisibility() && !RL.data().draftFolderNotEnabled() && !this.isEmptyForm(false) &&
!this.saving() && !this.sending() && !this.savedError())
!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
{
this.bSkipNext = false;
this.saveCommand();
}
}, this);

View file

@ -1,6 +1,6 @@
<?php
define('APP_INDEX_ROOT_PATH', rtrim(dirname(__FILE__), '\\/').'/');
define('APP_INDEX_ROOT_PATH', str_replace('\\', '/', rtrim(dirname(__FILE__), '\\/').'/'));
$sCustomDataPath = '';
if (file_exists(APP_INDEX_ROOT_PATH.'include.php'))

View file

@ -38,7 +38,14 @@ if (!\defined('RAINLOOP_APP_ROOT_PATH'))
if (!$oException)
{
\RainLoop\Service::NewInstance()->Handle();
if (defined('APP_CALLER_AS_API') && APP_CALLER_AS_API)
{
\RainLoop\Api::Handle();
}
else
{
\RainLoop\Service::NewInstance()->Handle();
}
}
}
}

View file

@ -159,6 +159,14 @@ class Actions
return $this->sSpecAuthToken;
}
/**
* @return string
*/
public function BuildSsoCacherKey($sSsoHash)
{
return '/Sso/Data/'.$sSsoHash.'/Login/';
}
/**
* @return \RainLoop\Application
*/
@ -4508,7 +4516,7 @@ class Actions
$sFolderFullName = $this->GetActionParam('MessageFolder', '');
$sUid = $this->GetActionParam('MessageUid', '');
$this->Cacher()->Set($oAccount->Email().'/'.$sFolderFullName.'/'.$sUid, '1');
$this->Cacher()->Set('/ReadReceipt/'.$oAccount->Email().'/'.$sFolderFullName.'/'.$sUid, '1');
if (0 < \strlen($sFolderFullName) && 0 < \strlen($sUid))
{
@ -6786,7 +6794,8 @@ class Actions
catch (\Exception $oException) {}
}
if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher()->Get($oAccount->Email().'/'.$mResult['Folder'].'/'.$mResult['Uid'], '0'))
if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher()->Get(
'/ReadReceipt/'.$oAccount->Email().'/'.$mResult['Folder'].'/'.$mResult['Uid'], '0'))
{
$mResult['ReadReceipt'] = '';
}
@ -6933,8 +6942,12 @@ class Actions
else if ($mResponse instanceof \MailSo\Base\Collection)
{
$aList =& $mResponse->GetAsArray();
if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection)
{
$aList = \array_slice($aList, 0, 100);
}
$mResult = $this->responseObject($aList, $sParent, $aParameters);
$bHook = false;
}
else

View file

@ -0,0 +1,89 @@
<?php
namespace RainLoop;
class Api
{
/**
* @return void
*/
private function __construct()
{
}
/**
* @return \RainLoop\Actions
*/
private static function Actions()
{
static $oActions = null;
if (null === $oActions)
{
$oActions = \RainLoop\Actions::NewInstance();
}
return $oActions;
}
/**
* @return \RainLoop\Application
*/
public static function Config()
{
return self::Actions()->Config();
}
/**
* @return bool
*/
public static function Handle()
{
static $bOne = null;
if ($bOne)
{
return true;
}
if (!\class_exists('MailSo\Version'))
{
return false;
}
if (self::Config()->Get('labs', 'disable_iconv_if_mbstring_supported') &&
\class_exists('MailSo\Capa') && \MailSo\Base\Utils::IsMbStringSupported())
{
\MailSo\Capa::$ICONV = false;
}
$bOne = true;
return true;
}
/**
* @param string $sEmail
* @param string $sPassword
* @param string $sLogin = ''
*
* @return string
*/
public static function GetUserSsoHash($sEmail, $sPassword, $sLogin = '')
{
$sSsoHash = \sha1(\rand(10000, 99999).$sEmail.$sPassword.$sLogin.\microtime(true));
return self::Actions()->Cacher()->Set(self::Actions()->BuildSsoCacherKey($sSsoHash), \RainLoop\Utils::EncodeKeyValues(array(
'Email' => $sEmail,
'Password' => $sPassword,
'Login' => $sLogin
))) ? $sSsoHash : '';
}
/**
* @param string $sSsoHash
*
* @return bool
*/
public static function ClearUserSsoHash($sSsoHash)
{
return self::Actions()->Delete(self::Actions()->BuildSsoCacherKey($sSsoHash));
}
}

View file

@ -296,7 +296,7 @@ abstract class PdoAbstract
}
/**
* @param string $sType
* @param string $sName
* @param bool $bReturnIntValue = true
*
* @return int|string|bool
@ -335,7 +335,7 @@ abstract class PdoAbstract
}
/**
* @param string $sType
* @param string $sName
*
* @return int|string|bool
*/
@ -345,7 +345,7 @@ abstract class PdoAbstract
}
/**
* @param string $sType
* @param string $sName
* @param int $iVersion
*
* @return bool

View file

@ -823,7 +823,52 @@ class ServiceActions
/**
* @return string
*/
public function ServiceCpanelAutoLogin()
public function ServiceSso()
{
$oException = null;
$oAccount = null;
$sSsoHash = $this->oHttp->GetRequest('hash', '');
if (!empty($sSsoHash))
{
$mData = null;
$sSsoKey = $this->oActions->BuildSsoCacherKey($sSsoHash);
$sSsoSubData = $this->Cacher()->Get($sSsoKey);
if (!empty($sSsoSubData))
{
$mData = \RainLoop\Utils::DecodeKeyValues($sSsoSubData);
$this->Cacher()->Delete($sSsoKey);
if (\is_array($mData) && !empty($mData['Email']) && isset($mData['Password']))
{
$sEmail = \strtolower(\trim($mData['Email']));
$sPassword = $mData['Password'];
$sLogin = isset($mData['Login']) ? $mData['Login'] : '';
try
{
$this->oActions->Logger()->AddSecret($sPassword);
$oAccount = $this->oActions->LoginProcess($sEmail, $sLogin, $sPassword);
$this->oActions->AuthProcess($oAccount);
}
catch (\Exception $oException)
{
$this->oActions->Logger()->WriteException($oException);
}
}
}
}
$this->oActions->Location('./');
return '';
}
/**
* @return string
*/
public function ServiceRemoteAutoLogin()
{
$oException = null;
$oAccount = null;

View file

@ -21,10 +21,10 @@
<tr><td>Open user dropdown</td><td>` (tilde)</td></tr>
<tr><td>Reply selected message</td><td>R</td></tr>
<tr><td>Reply All selected message</td><td>A</td></tr>
<tr><td>Froward selected message</td><td>F</td></tr>
<tr><td>Froward (multiply) selected messages</td><td>Shift + F</td></tr>
<tr><td>Open message list more dropdown</td><td></td></tr>
<tr><td>Open message view more dropdown</td><td></td></tr>
<tr><td>Forward selected message</td><td>F</td></tr>
<tr><td>Forward (multiply) selected messages</td><td>Shift + F</td></tr>
<!-- <tr><td>Open message list more dropdown</td><td></td></tr>
<tr><td>Open message view more dropdown</td><td></td></tr>-->
<tr><td>Help</td><td>?, Shift + /</td></tr>
</tbody>
</table>
@ -38,7 +38,7 @@
<tr><td>Archive selected messages</td><td>Z</td></tr>
<tr><td>Delete selected messages</td><td>Delete, Shift + delete</td></tr>
<tr><td>Move selected messages</td><td>M</td></tr>
<tr><td>Read selected messages</td><td>R</td></tr>
<tr><td>Read selected messages</td><td>Q</td></tr>
<tr><td>UnRead selected messages</td><td>U</td></tr>
<tr><td>Important, star/flag selected messages</td><td>I</td></tr>
<tr><td>Search</td><td>/</td></tr>

View file

@ -6,6 +6,9 @@
define('APP_INDEX_FILE', 'index.php');
define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/');
define('APP_CALLER_ROOT_PATH', empty($_SERVER['SCRIPT_FILENAME']) ? '' : str_replace('\\', '/', rtrim(dirname($_SERVER['SCRIPT_FILENAME']), '\\/').'/'));
define('APP_CALLER_AS_API', APP_CALLER_ROOT_PATH !== str_replace('\\', '/', APP_INDEX_ROOT_PATH));
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set('UTC');

View file

@ -8254,6 +8254,7 @@ function PopupsComposeViewModel()
this.aDraftInfo = null;
this.sInReplyTo = '';
this.bFromDraft = false;
this.bSkipNext = false;
this.sReferences = '';
this.bAllowIdentities = RL.settingsGet('AllowIdentities');
@ -8520,6 +8521,8 @@ function PopupsComposeViewModel()
this.savedError(false);
this.saving(true);
this.bSkipNext = true;
RL.cache().setFolderHash(RL.data().draftFolder(), '');
RL.remote().saveMessage(
@ -8545,8 +8548,9 @@ function PopupsComposeViewModel()
RL.sub('interval.1m', function () {
if (this.modalVisibility() && !RL.data().draftFolderNotEnabled() && !this.isEmptyForm(false) &&
!this.saving() && !this.sending() && !this.savedError())
!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
{
this.bSkipNext = false;
this.saveCommand();
}
}, this);
@ -19487,6 +19491,10 @@ RainLoopApp.prototype.bootstart = function ()
RL.quota();
});
RL.sub('interval.10m', function () {
RL.folders();
});
_.delay(function () {
RL.folderInformationMultiply(true);
}, 500);

File diff suppressed because one or more lines are too long