mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added: Password change plugin API improvements (#910)
This commit is contained in:
parent
b97bd4edf0
commit
cfad4bb005
11 changed files with 107 additions and 18 deletions
|
|
@ -271,7 +271,7 @@ class AbstractApp extends AbstractBoot
|
||||||
ko.components.register('TextArea', require('Component/TextArea'));
|
ko.components.register('TextArea', require('Component/TextArea'));
|
||||||
|
|
||||||
ko.components.register('x-script', require('Component/Script'));
|
ko.components.register('x-script', require('Component/Script'));
|
||||||
ko.components.register('svg-icon', require('Component/SvgIcon'));
|
// ko.components.register('svg-icon', require('Component/SvgIcon'));
|
||||||
|
|
||||||
if (/**false && /**/Settings.settingsGet('MaterialDesign') && Globals.bAnimationSupported)
|
if (/**false && /**/Settings.settingsGet('MaterialDesign') && Globals.bAnimationSupported)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import Translator from 'Common/Translator';
|
||||||
import Momentor from 'Common/Momentor';
|
import Momentor from 'Common/Momentor';
|
||||||
import Cache from 'Common/Cache';
|
import Cache from 'Common/Cache';
|
||||||
|
|
||||||
|
|
||||||
import SocialStore from 'Stores/Social';
|
import SocialStore from 'Stores/Social';
|
||||||
import SettingsStore from 'Stores/User/Settings';
|
import SettingsStore from 'Stores/User/Settings';
|
||||||
import AccountStore from 'Stores/User/Account';
|
import AccountStore from 'Stores/User/Account';
|
||||||
|
|
|
||||||
|
|
@ -233,11 +233,23 @@ class Translator
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defCode = defCode ? (window.parseInt(defCode, 10)) || 0 : 0;
|
||||||
return _.isUndefined(this.notificationI18N[code]) ? (
|
return _.isUndefined(this.notificationI18N[code]) ? (
|
||||||
defCode && _.isUndefined(this.notificationI18N[defCode]) ? this.notificationI18N[defCode] : ''
|
defCode && _.isUndefined(this.notificationI18N[defCode]) ? this.notificationI18N[defCode] : ''
|
||||||
) : this.notificationI18N[code];
|
) : this.notificationI18N[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {object} response
|
||||||
|
* @param {number} defCode = Notification.UnknownNotification
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getNotificationFromResponse(response, defCode = Notification.UnknownNotification) {
|
||||||
|
return response && response.ErrorCode ?
|
||||||
|
this.getNotification(Utils.pInt(response.ErrorCode), response.ErrorMessage || '') :
|
||||||
|
this.getNotification(defCode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} code
|
* @param {*} code
|
||||||
* @return {string}
|
* @return {string}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ let
|
||||||
getUtl = () => {
|
getUtl = () => {
|
||||||
if (!cachedUrl)
|
if (!cachedUrl)
|
||||||
{
|
{
|
||||||
const version = $('#rlAppVersion').attr('content') || '0.0.0';
|
const version = $('#rlAppVersion').attr('content') || '0.0.0'; // TODO
|
||||||
cachedUrl = `rainloop/v/${version}/static/css/svg/icons.svg`;
|
cachedUrl = `rainloop/v/${version}/static/css/svg/icons.svg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.passwordUpdateError(true);
|
this.passwordUpdateError(true);
|
||||||
this.errorDescription(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
this.errorDescription(
|
||||||
Translator.getNotification(Enums.Notification.CouldNotSaveNewPassword));
|
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@
|
||||||
oData.ErrorCode = Enums.Notification.AuthError;
|
oData.ErrorCode = Enums.Notification.AuthError;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
this.submitError(Translator.getNotificationFromResponse(oData));
|
||||||
|
|
||||||
if ('' === this.submitError())
|
if ('' === this.submitError())
|
||||||
{
|
{
|
||||||
|
|
@ -344,6 +344,11 @@
|
||||||
return bF || bG || bT;
|
return bF || bG || bT;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
|
||||||
|
{
|
||||||
|
this.submitError(Settings.settingsGet('AdditionalLoginError'));
|
||||||
|
}
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
kn.constructorEnd(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ class Actions
|
||||||
const AUTH_MAILTO_TOKEN_KEY = 'rlmailtoauth';
|
const AUTH_MAILTO_TOKEN_KEY = 'rlmailtoauth';
|
||||||
const AUTH_SPEC_TOKEN_KEY = 'rlspecauth';
|
const AUTH_SPEC_TOKEN_KEY = 'rlspecauth';
|
||||||
const AUTH_SPEC_LOGOUT_TOKEN_KEY = 'rlspeclogout';
|
const AUTH_SPEC_LOGOUT_TOKEN_KEY = 'rlspeclogout';
|
||||||
|
const AUTH_SPEC_LOGOUT_CUSTOM_MSG_KEY = 'rlspeclogoutcmk';
|
||||||
const AUTH_ADMIN_TOKEN_KEY = 'rlaauth';
|
const AUTH_ADMIN_TOKEN_KEY = 'rlaauth';
|
||||||
const AUTH_LAST_ERROR = 'rllasterrorcode';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \MailSo\Base\Http
|
* @var \MailSo\Base\Http
|
||||||
|
|
@ -644,6 +644,28 @@ class Actions
|
||||||
return $sResult;
|
return $sResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function GetSpecLogoutCustomMgsWithDeletion()
|
||||||
|
{
|
||||||
|
$sResult = \RainLoop\Utils::GetCookie(self::AUTH_SPEC_LOGOUT_CUSTOM_MSG_KEY, '');
|
||||||
|
if (0 < strlen($sResult))
|
||||||
|
{
|
||||||
|
\RainLoop\Utils::ClearCookie(self::AUTH_SPEC_LOGOUT_CUSTOM_MSG_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function SetSpecLogoutCustomMgsWithDeletion($sMessage)
|
||||||
|
{
|
||||||
|
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_CUSTOM_MSG_KEY, $sMessage, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -1597,6 +1619,11 @@ class Actions
|
||||||
$aResult['WelcomePageDisplay'] = '';
|
$aResult['WelcomePageDisplay'] = '';
|
||||||
|
|
||||||
$aResult['StartupUrl'] = '';
|
$aResult['StartupUrl'] = '';
|
||||||
|
|
||||||
|
if (empty($aResult['AdditionalLoginError']))
|
||||||
|
{
|
||||||
|
$aResult['AdditionalLoginError'] = $this->GetSpecLogoutCustomMgsWithDeletion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,29 @@ namespace RainLoop\Exceptions;
|
||||||
class ClientException extends Exception
|
class ClientException extends Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* @var boolen
|
||||||
|
*/
|
||||||
|
private $bLogoutOnException;
|
||||||
|
|
||||||
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $sAdditionalMessage;
|
private $sAdditionalMessage;
|
||||||
|
|
||||||
public function __construct($iCode, $oPrevious = null, $sAdditionalMessage = '')
|
/**
|
||||||
|
* @param int $iCode
|
||||||
|
* @param \Exception $oPrevious = null
|
||||||
|
* @param string $sAdditionalMessage = ''
|
||||||
|
* @param boolean $bLogoutOnException = false
|
||||||
|
*/
|
||||||
|
public function __construct($iCode, $oPrevious = null, $sAdditionalMessage = '', $bLogoutOnException = false)
|
||||||
{
|
{
|
||||||
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode, $oPrevious),
|
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode, $oPrevious),
|
||||||
$iCode, $oPrevious);
|
$iCode, $oPrevious);
|
||||||
|
|
||||||
$this->sAdditionalMessage = $sAdditionalMessage;
|
$this->sAdditionalMessage = $sAdditionalMessage;
|
||||||
|
|
||||||
|
$this->setLogoutOnException($bLogoutOnException);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -29,4 +41,27 @@ class ClientException extends Exception
|
||||||
{
|
{
|
||||||
return $this->sAdditionalMessage;
|
return $this->sAdditionalMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolen
|
||||||
|
*/
|
||||||
|
public function getLogoutOnException()
|
||||||
|
{
|
||||||
|
return $this->bLogoutOnException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $bLogoutOnException
|
||||||
|
* @param string $sAdditionalLogoutMessage = ''
|
||||||
|
*
|
||||||
|
* @return ClientException
|
||||||
|
*/
|
||||||
|
public function setLogoutOnException($bLogoutOnException, $sAdditionalLogoutMessage = '')
|
||||||
|
{
|
||||||
|
$this->bLogoutOnException = !!$bLogoutOnException;
|
||||||
|
|
||||||
|
$this->sAdditionalMessage = $sAdditionalLogoutMessage;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,14 +192,14 @@ class Service
|
||||||
}
|
}
|
||||||
|
|
||||||
$sResult .= '<!--';
|
$sResult .= '<!--';
|
||||||
$sResult .= ' [version:'.APP_VERSION;
|
$sResult .= ' [time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||||
|
|
||||||
|
// $sResult .= '][version:'.APP_VERSION;
|
||||||
if ($this->oActions->IsOpen())
|
if ($this->oActions->IsOpen())
|
||||||
{
|
{
|
||||||
$sResult .= '][AGPLv3';
|
$sResult .= '][AGPLv3';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sResult .= '][time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
|
||||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||||
// $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
// $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||||
// $sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
// $sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||||
|
|
|
||||||
|
|
@ -182,10 +182,22 @@ class ServiceActions
|
||||||
$aResponseItem = $this->oActions->ExceptionResponse(
|
$aResponseItem = $this->oActions->ExceptionResponse(
|
||||||
empty($sAction) ? 'Unknown' : $sAction, $oException);
|
empty($sAction) ? 'Unknown' : $sAction, $oException);
|
||||||
|
|
||||||
if (\is_array($aResponseItem) && 'Folders' === $sAction && $oException instanceof \RainLoop\Exceptions\ClientException)
|
if (\is_array($aResponseItem) && $oException instanceof \RainLoop\Exceptions\ClientException)
|
||||||
|
{
|
||||||
|
if ('Folders' === $sAction)
|
||||||
{
|
{
|
||||||
$aResponseItem['ClearAuth'] = true;
|
$aResponseItem['ClearAuth'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oException->getLogoutOnException())
|
||||||
|
{
|
||||||
|
$aResponseItem['Logout'] = true;
|
||||||
|
if ($oException->getAdditionalMessage())
|
||||||
|
{
|
||||||
|
$this->oActions->SetSpecLogoutCustomMgsWithDeletion($oException->getAdditionalMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_array($aResponseItem))
|
if (\is_array($aResponseItem))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
<meta name="Author" content="RainLoop Team" />
|
<meta name="Author" content="RainLoop Team" />
|
||||||
<meta name="robots" content="noindex,nofollow,noodp" />
|
<meta name="robots" content="noindex,nofollow,noodp" />
|
||||||
<meta name="google" content="notranslate" />
|
<meta name="google" content="notranslate" />
|
||||||
<meta name="app-version" content="{{BaseVersion}}" id="rlAppVersion" />
|
|
||||||
<title></title>
|
<title></title>
|
||||||
<style>#rl-content{display:none;}#rl-check{display:none;}</style>
|
<style>#rl-content{display:none;}#rl-check{display:none;}</style>
|
||||||
{{BaseAppFaviconPngLinkTag}}{{BaseAppFaviconTouchLinkTag}}
|
{{BaseAppFaviconPngLinkTag}}{{BaseAppFaviconTouchLinkTag}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue