Set response ErrorCode as iError for easier fetch error handling

This commit is contained in:
djmaze 2021-03-18 12:33:13 +01:00
parent a46c0c3b21
commit 11fd6736bb
24 changed files with 145 additions and 253 deletions

View file

@ -5,7 +5,6 @@ import { isPosNumeric, delegateRunOnDestroy, mailToHelper } from 'Common/UtilsUs
import { import {
Capa, Capa,
Notification,
Scope Scope
} from 'Common/Enums'; } from 'Common/Enums';
@ -179,13 +178,13 @@ class AppUser extends AbstractApp {
MessageUserStore.listError(''); MessageUserStore.listError('');
Remote.messageList( Remote.messageList(
(iError, oData, bCached) => { (iError, oData, bCached) => {
if (!iError && oData && oData.Result) { if (iError) {
MessageUserStore.setMessageList(oData, bCached); if (Notification.RequestAborted !== iError) {
} else if (Remote.ABORT !== iError) {
MessageUserStore.list([]); MessageUserStore.list([]);
MessageUserStore.listError( MessageUserStore.listError(getNotification(iError));
getNotification((oData && oData.ErrorCode) || Notification.CantGetMessageList) }
); } else {
MessageUserStore.setMessageList(oData, bCached);
} }
MessageUserStore.listLoading(false); MessageUserStore.listLoading(false);
}, },
@ -273,17 +272,15 @@ class AppUser extends AbstractApp {
} }
moveOrDeleteResponseHelper(iError, oData) { moveOrDeleteResponseHelper(iError, oData) {
if (!iError && FolderUserStore.currentFolder()) { if (iError) {
if (oData && isArray(oData.Result) && 2 === oData.Result.length) { setFolderHash(FolderUserStore.currentFolderFullNameRaw(), '');
alert(getNotification(iError));
} else if (FolderUserStore.currentFolder()) {
if (isArray(oData.Result) && 2 === oData.Result.length) {
setFolderHash(oData.Result[0], oData.Result[1]); setFolderHash(oData.Result[0], oData.Result[1]);
} else { } else {
setFolderHash(FolderUserStore.currentFolderFullNameRaw(), ''); setFolderHash(FolderUserStore.currentFolderFullNameRaw(), '');
if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) {
alert(getNotification(oData.ErrorCode));
} }
}
this.reloadMessageList(!MessageUserStore.list.length); this.reloadMessageList(!MessageUserStore.list.length);
this.quotaDebounce(); this.quotaDebounce();
} }
@ -763,7 +760,7 @@ class AppUser extends AbstractApp {
autocompleteCallback( autocompleteCallback(
data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null)).filter(v => v) data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null)).filter(v => v)
); );
} else if (Remote.ABORT !== iError) { } else if (Notification.RequestAborted !== iError) {
autocompleteCallback([]); autocompleteCallback([]);
} }
}, query); }, query);

View file

@ -77,6 +77,9 @@ export const SaveSettingsStep = {
* @enum {number} * @enum {number}
*/ */
export const Notification = { export const Notification = {
RequestError: 1,
RequestAborted: 2,
InvalidToken: 101, InvalidToken: 101,
AuthError: 102, AuthError: 102,
ConnectionError: 104, ConnectionError: 104,

View file

@ -92,29 +92,17 @@ function getNotificationMessage(code) {
* @param {*=} defCode = null * @param {*=} defCode = null
* @returns {string} * @returns {string}
*/ */
export function getNotification(code, message = '', defCode = null) { export function getNotification(code, message = '', defCode = 0) {
code = parseInt(code, 10) || 0; code = parseInt(code, 10) || 0;
if (Notification.ClientViewError === code && message) { if (Notification.ClientViewError === code && message) {
return message; return message;
} }
defCode = defCode ? parseInt(defCode, 10) || 0 : 0;
return getNotificationMessage(code) return getNotificationMessage(code)
|| getNotificationMessage(defCode) || getNotificationMessage(parseInt(defCode, 10))
|| ''; || '';
} }
/**
* @param {object} response
* @param {number} defCode = Notification.UnknownNotification
* @returns {string}
*/
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification) {
return response && response.ErrorCode
? getNotification(parseInt(response.ErrorCode, 10) || defCode, response.ErrorMessage || '')
: getNotification(defCode);
}
/** /**
* @param {*} code * @param {*} code
* @returns {string} * @returns {string}

View file

@ -32,11 +32,9 @@ checkResponseError = data => {
) { ) {
++iJsonErrorCount; ++iJsonErrorCount;
} }
if (window.rl && (data.ClearAuth || data.Logout || 7 < iJsonErrorCount)) { if (data.ClearAuth || data.Logout || 7 < iJsonErrorCount) {
rl.hash.clear(); rl.hash.clear();
if (!data.ClearAuth) { data.ClearAuth || rl.logoutReload();
rl.logoutReload();
}
} }
} }
}, },
@ -116,10 +114,16 @@ export class AbstractFetchRemote
} }
if (!iError && data) { if (!iError && data) {
/*
if (sAction !== data.Action) {
console.log(sAction + ' !== ' + data.Action);
}
*/
if (data.Result) { if (data.Result) {
iJsonErrorCount = iTokenErrorCount = 0; iJsonErrorCount = iTokenErrorCount = 0;
} else { } else {
checkResponseError(data); checkResponseError(data);
iError = data.ErrorCode || Notification.UnknownError
} }
} }

View file

@ -35,15 +35,12 @@ export class PackagesAdminSettings {
requestHelper(packageToRequest, install) { requestHelper(packageToRequest, install) {
return (iError, data) => { return (iError, data) => {
if (iError || !data || !data.Result) { if (iError) {
if (data && data.ErrorCode) {
this.packagesError(getNotification(data.ErrorCode));
} else {
this.packagesError( this.packagesError(
getNotification(install ? Notification.CantInstallPackage : Notification.CantDeletePackage) getNotification(install ? Notification.CantInstallPackage : Notification.CantDeletePackage)
// ':\n' + getNotification(iError);
); );
} }
}
PackageAdminStore.forEach(item => { PackageAdminStore.forEach(item => {
if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file) { if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file) {
@ -52,7 +49,7 @@ export class PackagesAdminSettings {
} }
}); });
if (!iError && data && data.Result && data.Result.Reload) { if (!iError && data.Result.Reload) {
location.reload(); location.reload();
} else { } else {
PackageAdminStore.fetch(); PackageAdminStore.fetch();

View file

@ -60,13 +60,11 @@ export class PluginsAdminSettings {
} }
onPluginDisableRequest(iError, data) { onPluginDisableRequest(iError, data) {
if (!iError && data) { if (iError) {
if (!data.Result && data.ErrorCode) { if (Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage) {
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && data.ErrorMessage) {
PluginAdminStore.error(data.ErrorMessage); PluginAdminStore.error(data.ErrorMessage);
} else { } else {
PluginAdminStore.error(getNotification(data.ErrorCode)); PluginAdminStore.error(getNotification(iError));
}
} }
} }

View file

@ -1,6 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { Notification } from 'Common/Enums';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
import { addObservablesTo } from 'Common/Utils'; import { addObservablesTo } from 'Common/Utils';
import { delegateRunOnDestroy } from 'Common/UtilsUser'; import { delegateRunOnDestroy } from 'Common/UtilsUser';
@ -41,7 +40,10 @@ export class FiltersUserSettings {
this.loading(false); this.loading(false);
this.scripts([]); this.scripts([]);
if (!iError && data && data.Result) { if (iError) {
SieveUserStore.capa([]);
this.setError(getNotification(iError));
} else {
SieveUserStore.capa(data.Result.Capa); SieveUserStore.capa(data.Result.Capa);
/* /*
this.scripts( this.scripts(
@ -52,11 +54,6 @@ export class FiltersUserSettings {
value = SieveScriptModel.reviveFromJson(value); value = SieveScriptModel.reviveFromJson(value);
value && this.scripts.push(value) value && this.scripts.push(value)
}); });
} else {
SieveUserStore.capa([]);
this.setError(
data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters)
);
} }
}); });
} }
@ -73,15 +70,12 @@ export class FiltersUserSettings {
deleteScript(script) { deleteScript(script) {
this.serverError(false); this.serverError(false);
Remote.filtersScriptDelete( Remote.filtersScriptDelete(
(result, data) => { (iError, data) => {
if (Remote.SUCCESS === result && data && data.Result) { if (iError) {
this.setError((data && data.ErrorMessageAdditional) || getNotification(iError));
} else {
this.scripts.remove(script); this.scripts.remove(script);
delegateRunOnDestroy(script); delegateRunOnDestroy(script);
} else {
this.setError((data && data.ErrorCode)
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
: getNotification(Notification.CantActivateFiltersScript)
);
} }
}, },
script.name() script.name()
@ -92,14 +86,11 @@ export class FiltersUserSettings {
let name = script.active() ? '' : script.name(); let name = script.active() ? '' : script.name();
this.serverError(false); this.serverError(false);
Remote.filtersScriptActivate( Remote.filtersScriptActivate(
(result, data) => { (iError, data) => {
if (Remote.SUCCESS === result && data && data.Result) { if (iError) {
this.scripts.forEach(script => script.active(script.name() === name)); this.setError((data && data.ErrorMessageAdditional) || iError)
} else { } else {
this.setError((data && data.ErrorCode) this.scripts.forEach(script => script.active(script.name() === name));
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
: getNotification(Notification.CantActivateFiltersScript)
);
} }
}, },
name name

View file

@ -640,15 +640,14 @@ export const MessageUserStore = new class {
* @param {boolean} bCached * @param {boolean} bCached
*/ */
onMessageResponse(iError, oData, bCached) { onMessageResponse(iError, oData, bCached) {
if (!iError && oData && oData.Result) { if (iError) {
this.setMessage(oData, bCached); if (Notification.RequestAborted !== iError) {
} else if (Remote.ABORT !== iError) {
this.message(null); this.message(null);
this.messageError( this.messageError(getNotification(iError));
oData && oData.ErrorCode ? getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError) }
); } else {
this.setMessage(oData, bCached);
} }
this.messageLoading(false); this.messageLoading(false);
} }
@ -663,7 +662,7 @@ export const MessageUserStore = new class {
} }
setMessageList(data, cached) { setMessageList(data, cached) {
const collection = data && MessageCollectionModel.reviveFromJson(data.Result, cached); const collection = MessageCollectionModel.reviveFromJson(data.Result, cached);
if (collection) { if (collection) {
let unreadCountChange = false; let unreadCountChange = false;
@ -715,7 +714,7 @@ export const MessageUserStore = new class {
} else { } else {
this.listCount(0); this.listCount(0);
this.list([]); this.list([]);
this.listError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList)); this.listError(getNotification(Notification.CantGetMessageList));
} }
} }
}; };

View file

@ -1,6 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { Notification } from 'Common/Enums';
import { Settings } from 'Common/Globals'; import { Settings } from 'Common/Globals';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
@ -59,17 +58,12 @@ class LoginAdminView extends AbstractViewCenter {
this.submitRequest(true); this.submitRequest(true);
Remote.adminLogin( Remote.adminLogin(
(iError, oData) => { (iError) => {
if (!iError && oData && 'AdminLogin' === oData.Action) {
if (oData.Result) {
rl.route.reload();
} else if (oData.ErrorCode) {
this.submitRequest(false); this.submitRequest(false);
this.submitError(getNotification(oData.ErrorCode)); if (iError) {
} this.submitError(getNotification(iError));
} else { } else {
this.submitRequest(false); rl.route.reload();
this.submitError(getNotification(Notification.UnknownError));
} }
}, },
this.login(), this.login(),

View file

@ -1,4 +1,3 @@
import { Notification } from 'Common/Enums';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
import Remote from 'Remote/User/Fetch'; import Remote from 'Remote/User/Fetch';
@ -48,22 +47,12 @@ class AccountPopupView extends AbstractViewPopup {
Remote.accountSetup( Remote.accountSetup(
(iError, data) => { (iError, data) => {
this.submitRequest(false); this.submitRequest(false);
if (!iError && data) { if (iError) {
if (data.Result) { this.submitError(getNotification(iError));
this.submitErrorAdditional((data && data.ErrorMessageAdditional) || '');
} else {
rl.app.accountsAndIdentities(); rl.app.accountsAndIdentities();
this.cancelCommand(); this.cancelCommand();
} else {
this.submitError(
data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.UnknownError)
);
if (data.ErrorMessageAdditional) {
this.submitErrorAdditional(data.ErrorMessageAdditional);
}
}
} else {
this.submitError(getNotification(Notification.UnknownError));
this.submitErrorAdditional('');
} }
}, },
this.email(), this.email(),

View file

@ -579,28 +579,21 @@ class ComposePopupView extends AbstractViewPopup {
} }
sendMessageResponse(iError, data) { sendMessageResponse(iError, data) {
let result = false,
message = '';
this.sending(false); this.sending(false);
if (!iError && data && data.Result) { if (this.modalVisibility()) {
result = true; if (iError) {
this.modalVisibility() && this.closeCommand && this.closeCommand(); if (Notification.CantSaveMessage === iError) {
}
if (this.modalVisibility() && !result) {
if (data && Notification.CantSaveMessage === data.ErrorCode) {
this.sendSuccessButSaveError(true); this.sendSuccessButSaveError(true);
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim()); this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
} else { } else {
message = getNotification(
data && data.ErrorCode ? data.ErrorCode : Notification.CantSendMessage,
data && data.ErrorMessage ? data.ErrorMessage : ''
);
this.sendError(true); this.sendError(true);
this.sendErrorDesc(message || getNotification(Notification.CantSendMessage)); this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|| getNotification(Notification.CantSendMessage));
}
} else {
this.closeCommand && this.closeCommand();
} }
} }

View file

@ -2,7 +2,6 @@ import ko from 'ko';
import { import {
SaveSettingsStep, SaveSettingsStep,
Notification,
Scope Scope
} from 'Common/Enums'; } from 'Common/Enums';
@ -255,10 +254,8 @@ class ContactsPopupView extends AbstractViewPopup {
} }
syncCommand() { syncCommand() {
rl.app.contactsSync((iError, data) => { rl.app.contactsSync(iError => {
if (iError || !data || !data.Result) { iError && alert(getNotification(iError));
alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
}
this.reloadContactList(true); this.reloadContactList(true);
}); });

View file

@ -1,6 +1,5 @@
import { Notification } from 'Common/Enums';
import { pInt, pString } from 'Common/Utils'; import { pInt, pString } from 'Common/Utils';
import { i18n } from 'Common/Translator'; import { i18n, getNotification } from 'Common/Translator';
import Remote from 'Remote/Admin/Fetch'; import Remote from 'Remote/Admin/Fetch';
@ -248,17 +247,13 @@ class DomainPopupView extends AbstractViewPopup {
} }
} }
onDomainCreateOrSaveResponse(iError, oData) { onDomainCreateOrSaveResponse(iError) {
this.saving(false); this.saving(false);
if (!iError && oData) { if (iError) {
if (oData.Result) { this.savingError(getNotification(iError));
} else {
DomainAdminStore.fetch(); DomainAdminStore.fetch();
this.closeCommand(); this.closeCommand();
} else if (Notification.DomainAlreadyExists === oData.ErrorCode) {
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
}
} else {
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
} }
} }

View file

@ -1,7 +1,6 @@
import ko from 'ko'; import ko from 'ko';
import { Notification } from 'Common/Enums'; import { getNotification } from 'Common/Translator';
import { i18n } from 'Common/Translator';
import { DomainAdminStore } from 'Stores/Admin/Domain'; import { DomainAdminStore } from 'Stores/Admin/Domain';
@ -29,8 +28,6 @@ class DomainAliasPopupView extends AbstractViewPopup {
this.canBeSaved = ko.computed(() => !this.saving() && this.name() && this.alias()); this.canBeSaved = ko.computed(() => !this.saving() && this.name() && this.alias());
this.onDomainAliasCreateOrSaveResponse = this.onDomainAliasCreateOrSaveResponse.bind(this);
decorateKoCommands(this, { decorateKoCommands(this, {
createCommand: self => self.canBeSaved() createCommand: self => self.canBeSaved()
}); });
@ -38,21 +35,15 @@ class DomainAliasPopupView extends AbstractViewPopup {
createCommand() { createCommand() {
this.saving(true); this.saving(true);
Remote.createDomainAlias(this.onDomainAliasCreateOrSaveResponse, this.name(), this.alias()); Remote.createDomainAlias(iError => {
}
onDomainAliasCreateOrSaveResponse(iError, data) {
this.saving(false); this.saving(false);
if (!iError && data) { if (iError) {
if (data.Result) { this.savingError(getNotification(iError));
} else {
DomainAdminStore.fetch(); DomainAdminStore.fetch();
this.closeCommand(); this.closeCommand();
} else if (Notification.DomainAlreadyExists === data.ErrorCode) {
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
}
} else {
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
} }
}, this.name(), this.alias());
} }
onShow() { onShow() {

View file

@ -1,4 +1,3 @@
import { Notification } from 'Common/Enums';
import { i18n, getNotification } from 'Common/Translator'; import { i18n, getNotification } from 'Common/Translator';
import { setFolderHash } from 'Common/Cache'; import { setFolderHash } from 'Common/Cache';
@ -54,17 +53,13 @@ class FolderClearPopupView extends AbstractViewPopup {
setFolderHash(folderToClear.fullNameRaw, ''); setFolderHash(folderToClear.fullNameRaw, '');
Remote.folderClear((iError, data) => { Remote.folderClear(iError => {
this.clearingProcess(false); this.clearingProcess(false);
if (!iError && data && data.Result) { if (iError) {
this.clearingError(getNotification(iError));
} else {
rl.app.reloadMessageList(true); rl.app.reloadMessageList(true);
this.cancelCommand(); this.cancelCommand();
} else {
if (data && data.ErrorCode) {
this.clearingError(getNotification(data.ErrorCode));
} else {
this.clearingError(getNotification(Notification.MailServerError));
}
} }
}, folderToClear.fullNameRaw); }, folderToClear.fullNameRaw);
} }

View file

@ -1,4 +1,3 @@
import { Notification } from 'Common/Enums';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
import Remote from 'Remote/User/Fetch'; import Remote from 'Remote/User/Fetch';
@ -96,17 +95,13 @@ class IdentityPopupView extends AbstractViewPopup {
this.submitRequest(true); this.submitRequest(true);
Remote.identityUpdate( Remote.identityUpdate(
(iError, data) => { iError => {
this.submitRequest(false); this.submitRequest(false);
if (!iError && data) { if (iError) {
if (data.Result) { this.submitError(getNotification(iError));
} else {
rl.app.accountsAndIdentities(); rl.app.accountsAndIdentities();
this.cancelCommand(); this.cancelCommand();
} else if (data.ErrorCode) {
this.submitError(getNotification(data.ErrorCode));
}
} else {
this.submitError(getNotification(Notification.UnknownError));
} }
}, },
this.id, this.id,

View file

@ -1,6 +1,6 @@
import ko from 'ko'; import ko from 'ko';
import { Scope, Notification } from 'Common/Enums'; import { Scope } from 'Common/Enums';
import { getNotification, i18n } from 'Common/Translator'; import { getNotification, i18n } from 'Common/Translator';
import { isNonEmptyArray } from 'Common/Utils'; import { isNonEmptyArray } from 'Common/Utils';
@ -53,16 +53,11 @@ class PluginPopupView extends AbstractViewPopup {
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list); Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
} }
onPluginSettingsUpdateResponse(iError, data) { onPluginSettingsUpdateResponse(iError) {
if (!iError && data && data.Result) { if (iError) {
this.saveError(getNotification(iError));
} else {
this.cancelCommand(); this.cancelCommand();
} else {
this.saveError('');
if (data && data.ErrorCode) {
this.saveError(getNotification(data.ErrorCode));
} else {
this.saveError(getNotification(Notification.CantSavePluginSettings));
}
} }
} }

View file

@ -1,6 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { Notification } from 'Common/Enums';
import { getNotification, i18nToNodes } from 'Common/Translator'; import { getNotification, i18nToNodes } from 'Common/Translator';
import { addObservablesTo } from 'Common/Utils'; import { addObservablesTo } from 'Common/Utils';
import { delegateRunOnDestroy } from 'Common/UtilsUser'; import { delegateRunOnDestroy } from 'Common/UtilsUser';
@ -61,16 +60,13 @@ class SieveScriptPopupView extends AbstractViewPopup {
(iError, data) => { (iError, data) => {
self.saving = false; self.saving = false;
if (!iError && data && data.Result) { if (iError) {
self.saveError(true);
self.saveErrorText((data && data.ErrorMessageAdditional) || getNotification(iError));
} else {
script.exists() || SieveUserStore.scripts.push(script); script.exists() || SieveUserStore.scripts.push(script);
script.exists(true); script.exists(true);
script.hasChanges(false); script.hasChanges(false);
} else {
self.saveError(true);
self.saveErrorText((data && data.ErrorCode)
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
: getNotification(Notification.CantSaveFilters)
);
} }
}, },
script script

View file

@ -1,4 +1,3 @@
import { Notification } from 'Common/Enums';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
import { HtmlEditor } from 'Common/Html'; import { HtmlEditor } from 'Common/Html';
@ -53,17 +52,13 @@ class TemplatePopupView extends AbstractViewPopup {
this.submitRequest(true); this.submitRequest(true);
Remote.templateSetup( Remote.templateSetup(
(iError, data) => { iError => {
this.submitRequest(false); this.submitRequest(false);
if (!iError && data) { if (iError) {
if (data.Result) { this.submitError(getNotification(iError));
} else {
rl.app.templates(); rl.app.templates();
this.cancelCommand(); this.cancelCommand();
} else if (data.ErrorCode) {
this.submitError(getNotification(data.ErrorCode));
}
} else {
this.submitError(getNotification(Notification.UnknownError));
} }
}, },
this.id(), this.id(),

View file

@ -6,7 +6,7 @@ import {
import { ClientSideKeyName } from 'Common/EnumsUser'; import { ClientSideKeyName } from 'Common/EnumsUser';
import { getNotification, getNotificationFromResponse, reload as translatorReload, convertLangName } from 'Common/Translator'; import { getNotification, reload as translatorReload, convertLangName } from 'Common/Translator';
import { LanguageStore } from 'Stores/Language'; import { LanguageStore } from 'Stores/Language';
@ -150,36 +150,21 @@ class LoginUserView extends AbstractViewCenter {
const fLoginRequest = (sLoginPassword) => { const fLoginRequest = (sLoginPassword) => {
Remote.login( Remote.login(
(iError, oData) => { (iError, oData) => {
if (!iError && oData && 'Login' === oData.Action) { this.submitRequest(false);
if (oData.Result) { if (iError) {
if (Notification.InvalidInputArgument == iError) {
iError = Notification.AuthError;
}
this.submitError(getNotification(iError, oData.ErrorMessage, Notification.UnknownNotification));
this.submitErrorAddidional((oData && oData.ErrorMessageAdditional) || '');
} else {
if (oData.TwoFactorAuth) { if (oData.TwoFactorAuth) {
this.additionalCode(''); this.additionalCode('');
this.additionalCodeVisibility(true); this.additionalCodeVisibility(true);
this.submitRequest(false);
setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100); setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100);
} else { } else {
rl.route.reload(); rl.route.reload();
} }
} else if (oData.ErrorCode) {
this.submitRequest(false);
if ([Notification.InvalidInputArgument].includes(oData.ErrorCode)) {
oData.ErrorCode = Notification.AuthError;
}
this.submitError(getNotificationFromResponse(oData));
if (!this.submitError()) {
this.submitError(getNotification(Notification.UnknownError));
} else if (oData.ErrorMessageAdditional) {
this.submitErrorAddidional(oData.ErrorMessageAdditional);
}
} else {
this.submitRequest(false);
}
} else {
this.submitRequest(false);
this.submitError(getNotification(Notification.UnknownError));
} }
}, },
this.email(), this.email(),

3
dev/bootstrap.js vendored
View file

@ -37,8 +37,7 @@ export default (App) => {
StorageResultType: { StorageResultType: {
Success: 0, Success: 0,
Error: 1, Error: 1,
Abort: 2, Abort: 2
Unload: 3
} }
}; };

View file

@ -108,25 +108,21 @@
onChangePasswordResponse(iError, data) { onChangePasswordResponse(iError, data) {
this.reset(false); this.reset(false);
if (!iError && data && data.Result) { if (iError) {
this.passwordUpdateError(true);
if (131 === iError) {
// Notification.CurrentPasswordIncorrect
this.currentPasswordError(true);
}
this.errorDescription((data && data.ErrorMessageAdditional)
|| rl.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'));
} else {
this.currentPassword(''); this.currentPassword('');
this.newPassword(''); this.newPassword('');
this.newPassword2(''); this.newPassword2('');
this.passwordUpdateSuccess(true); this.passwordUpdateSuccess(true);
rl.hash.set(); rl.hash.set();
rl.settings.set('AuthAccountHash', data.Result); rl.settings.set('AuthAccountHash', data.Result);
} else {
this.passwordUpdateError(true);
this.errorDescription(rl.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'));
if (data) {
if (131 === data.ErrorCode) {
// Notification.CurrentPasswordIncorrect
this.currentPasswordError(true);
}
if (data.ErrorMessageAdditional) {
this.errorDescription(data.ErrorMessageAdditional);
}
}
} }
} }
} }

View file

@ -22,11 +22,11 @@
this.loading(true); this.loading(true);
rl.pluginRemoteRequest(function (iError, oData) { rl.pluginRemoteRequest((iError, oData) => {
self.loading(false); self.loading(false);
if (!iError && oData && oData.Result) { if (!iError) {
self.php(oData.Result.PHP || ''); self.php(oData.Result.PHP || '');
} }

View file

@ -33,11 +33,11 @@
this.saving(true); this.saving(true);
rl.pluginRemoteRequest(function (iError, oData) { rl.pluginRemoteRequest((iError, oData) => {
self.saving(false); self.saving(false);
if (!iError && oData && oData.Result) if (!iError)
{ {
// true // true
} }
@ -61,11 +61,11 @@
this.loading(true); this.loading(true);
rl.pluginRemoteRequest(function (iError, oData) { rl.pluginRemoteRequest((iError, oData) => {
self.loading(false); self.loading(false);
if (!iError && oData && oData.Result) if (!iError)
{ {
self.userSkype(oData.Result.UserSkype || ''); self.userSkype(oData.Result.UserSkype || '');
self.userFacebook(oData.Result.UserFacebook || ''); self.userFacebook(oData.Result.UserFacebook || '');