Added additional account edit form

This commit is contained in:
RainLoop Team 2014-10-21 20:49:15 +04:00
parent c6ec3fb311
commit ebb6a06c65
36 changed files with 149 additions and 59 deletions

View file

@ -398,7 +398,7 @@ class Actions
*/
public function SetAuthLogoutToken()
{
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, \md5(APP_START_TIME), 0, '/', null, null, true);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0, '/', null, null, true);
}
/**
@ -764,7 +764,7 @@ class Actions
'[APC:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('apc_fetch') ? 'on' : 'off').']'.
'[MB:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding') ? 'on' : 'off').']'.
'[PDO:'.(\class_exists('PDO') ? \implode(',', \PDO::getAvailableDrivers()) : 'off').']'.
'[Streams:'.\implode(',', \stream_get_transports()).']'
'['.\implode(',', \stream_get_transports()).']'
);
$this->oLogger->Write(
@ -1941,7 +1941,7 @@ class Actions
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoAccountAdd()
public function DoAccountSetup()
{
if (!$this->Config()->Get('webmail', 'allow_additional_accounts', true))
{
@ -1949,38 +1949,32 @@ class Actions
}
$oAccount = $this->getAccountFromToken();
$sParentEmail = $oAccount->ParentEmailHelper();
$aAccounts = $this->GetAccounts($oAccount);
if (!\is_array($aAccounts))
{
$aAccounts = array();
}
$sEmail = \trim($this->GetActionParam('Email', ''));
$sPassword = $this->GetActionParam('Password', '');
$sParentEmail = $oAccount->ParentEmailHelper();
$bNew = '1' === (string) $this->GetActionParam('New', '1');
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
if ($oAccount->Email() === $sEmail || $sParentEmail === $sEmail)
if ($bNew && ($oAccount->Email() === $sEmail || $sParentEmail === $sEmail || isset($aAccounts[$sEmail])))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountAlreadyExists);
}
else if (!$bNew && !isset($aAccounts[$sEmail]))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountDoesNotExist);
}
$oNewAccount = $this->LoginProcess($sEmail, $sPassword);
$oNewAccount->SetParentEmail($sParentEmail);
$aAccounts = $this->GetAccounts($oAccount);
if (\is_array($aAccounts))
{
if (isset($aAccounts[$oNewAccount->Email()]))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountAlreadyExists);
}
else
{
$aAccounts[$oNewAccount->Email()] = $oNewAccount->GetAuthToken();
}
}
else
{
$aAccounts = array();
}
$aAccounts[$oNewAccount->Email()] = $oNewAccount->GetAuthToken();
if (0 === \strlen($oAccount->ParentEmail()))
{
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
@ -2211,6 +2205,11 @@ class Actions
$this->ClearSignMeData($oAccount);
}
if ($oAccount && '' === $oAccount->ParentEmail())
{
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SPEC_TOKEN_KEY);
}
return $this->TrueResponse(__FUNCTION__);
}

View file

@ -14,7 +14,7 @@ class Notifications
const SocialGoogleLoginAccessDisable = 108;
const DomainNotAllowed = 109;
const AccountNotAllowed = 110;
const AccountTwoFactorAuthRequired = 120;
const AccountTwoFactorAuthError = 121;
@ -47,20 +47,21 @@ class Notifications
const CantSavePluginSettings = 502;
const DomainAlreadyExists = 601;
const CantInstallPackage = 701;
const CantDeletePackage = 702;
const InvalidPluginPackage = 703;
const UnsupportedPluginPackage = 704;
const LicensingServerIsUnavailable = 710;
const LicensingExpired = 711;
const LicensingBanned = 712;
const DemoSendMessageError = 750;
const AccountAlreadyExists = 801;
const AccountDoesNotExist = 802;
const MailServerError = 901;
const ClientViewError = 902;
const InvalidInputArgument = 903;
@ -69,10 +70,10 @@ class Notifications
/**
* @staticvar array $aMap
*
*
* @param int $iCode
* @param \Exception|null $oPrevious
*
*
* @return string
*/
static public function GetNotificationsMessage($iCode, $oPrevious = null)
@ -98,7 +99,7 @@ class Notifications
self::NewPasswordForbidden => 'NewPasswordForbidden',
self::ContactsSyncError => 'ContactsSyncError',
self::CantGetMessageList => 'CantGetMessageList',
self::CantGetMessage => 'CantGetMessage',
self::CantDeleteMessage => 'CantDeleteMessage',
@ -124,6 +125,7 @@ class Notifications
self::LicensingBanned => 'LicensingBanned',
self::DemoSendMessageError => 'DemoSendMessageError',
self::AccountAlreadyExists => 'AccountAlreadyExists',
self::AccountDoesNotExist => 'AccountDoesNotExist',
self::MailServerError => 'MailServerError',
self::ClientViewError => 'ClientViewError',
self::InvalidInputArgument => 'InvalidInputArgument',

View file

@ -4,7 +4,8 @@
<div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
<span class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/TITLE_ADD_ACCOUNT"></span>
<span data-bind="visible: isNew" class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/TITLE_ADD_ACCOUNT"></span>
<span data-bind="visible: !isNew()" class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/TITLE_UPDATE_ACCOUNT"></span>
</h3>
</div>
<div class="modal-body">
@ -17,8 +18,9 @@
<div class="control-group" data-bind="css: {'error': emailError}">
<label class="i18n control-label" data-i18n-text="LOGIN/LABEL_EMAIL"></label>
<div class="controls">
<label style="margin-top: 5px;"><strong data-bind="visible: !isNew(), text: email"></strong></label>
<input type="email" class="inputEmail input-large" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: email, onEnter: addAccountCommand, hasfocus: emailFocus" />
data-bind="visible: isNew, textInput: email, onEnter: addAccountCommand, hasfocus: emailFocus" />
</div>
</div>
<div class="control-group" data-bind="css: {'error': passwordError}">
@ -32,9 +34,11 @@
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addAccountCommand">
<i data-bind="css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: isNew, css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: !isNew(), css: {'icon-ok': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/BUTTON_ADD_ACCOUNT"></span>
<span data-bind="visible: isNew" class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/BUTTON_ADD_ACCOUNT"></span>
<span data-bind="visible: !isNew()" class="i18n" data-i18n-text="POPUPS_ADD_ACCOUNT/BUTTON_UPDATE_ACCOUNT"></span>
</a>
</div>
</div>

View file

@ -4,7 +4,8 @@
<div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
<span data-bind="text: label"></span>
<span data-bind="visible: !edit()" class="i18n" data-i18n-text="POPUPS_IDENTITIES/TITLE_ADD_IDENTITY"></span>
<span data-bind="visible: edit" class="i18n" data-i18n-text="POPUPS_IDENTITIES/TITLE_UPDATE_IDENTITY"></span>
</h3>
</div>
<div class="modal-body">
@ -56,9 +57,11 @@
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addOrEditIdentityCommand">
<i data-bind="css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: !edit(), css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: edit, css: {'icon-ok': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp;
<span data-bind="text: button"></span>
<span data-bind="visible: !edit()" class="i18n" data-i18n-text="POPUPS_IDENTITIES/BUTTON_ADD_IDENTITY"></span>
<span data-bind="visible: edit" class="i18n" data-i18n-text="POPUPS_IDENTITIES/BUTTON_UPDATE_IDENTITY"></span>
</a>
</div>
</div>

View file

@ -17,14 +17,18 @@
<table class="table table-hover list-table" data-bind="i18nUpdate: accounts">
<colgroup>
<col />
<col style="width: 150px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="foreach: accounts">
<tr class="account-item">
<td>
<td class="e-action" data-bind="css: {'e-action': canBeEdit}">
<span class="account-img icon-user"></span>
<span class="account-name" data-bind="text: email"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="css: {'delete-access': deleteAccess()}, click: function(oAccount) { $root.deleteAccount(oAccount); }">
</td>
<td>
<span data-bind="visible: !canBeDalete()"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="visible: canBeDalete, css: {'delete-access': deleteAccess}, click: function(oAccount) { $root.deleteAccount(oAccount); }">
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/DELETING_ASK"></span>
</a>
</td>