mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Change handling of (token) errors due to #1706
This commit is contained in:
parent
02ea6c4359
commit
d00c953c88
25 changed files with 80 additions and 69 deletions
|
|
@ -27,7 +27,7 @@ import {
|
||||||
getFolderFromCacheList
|
getFolderFromCacheList
|
||||||
} from 'Common/Cache';
|
} from 'Common/Cache';
|
||||||
|
|
||||||
import { i18n, reloadTime } from 'Common/Translator';
|
import { i18n, reloadTime, getErrorMessage } from 'Common/Translator';
|
||||||
|
|
||||||
import { SettingsUserStore } from 'Stores/User/Settings';
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
||||||
import { NotificationUserStore } from 'Stores/User/Notification';
|
import { NotificationUserStore } from 'Stores/User/Notification';
|
||||||
|
|
@ -150,7 +150,8 @@ export class AppUser extends AbstractApp {
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
Remote.request('Logout', (iError, data) =>
|
Remote.request('Logout', (iError, data) =>
|
||||||
iError ? alert(data) : rl.logoutReload(Settings.app('customLogoutLink'))
|
iError ? alert('Logout error: ' + getErrorMessage(iError, data))
|
||||||
|
: rl.logoutReload(Settings.app('customLogoutLink'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,9 +184,9 @@ export class AppUser extends AbstractApp {
|
||||||
SettingsUserStore.init();
|
SettingsUserStore.init();
|
||||||
ContactUserStore.init();
|
ContactUserStore.init();
|
||||||
|
|
||||||
loadFolders(value => {
|
loadFolders((success, error) => {
|
||||||
try {
|
try {
|
||||||
if (value) {
|
if (success) {
|
||||||
startScreens([
|
startScreens([
|
||||||
MailBoxUserScreen,
|
MailBoxUserScreen,
|
||||||
SettingsUserScreen
|
SettingsUserScreen
|
||||||
|
|
@ -227,6 +228,7 @@ export class AppUser extends AbstractApp {
|
||||||
setTimeout(() => mailToHelper(SettingsGet('mailToEmail')), 500);
|
setTimeout(() => mailToHelper(SettingsGet('mailToEmail')), 500);
|
||||||
} else {
|
} else {
|
||||||
this.logout();
|
this.logout();
|
||||||
|
alert('Folders error: ' + getErrorMessage(0, error))
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ dropFilesInFolder = (sFolderFullName, files) => {
|
||||||
data.append('folder', sFolderFullName);
|
data.append('folder', sFolderFullName);
|
||||||
data.append('appendFile', file);
|
data.append('appendFile', file);
|
||||||
Remote.request('FolderAppend', (iError, data)=>{
|
Remote.request('FolderAppend', (iError, data)=>{
|
||||||
iError && console.error(data.ErrorMessage);
|
iError && console.error(data.message);
|
||||||
0 == --count
|
0 == --count
|
||||||
&& FolderUserStore.currentFolderFullName() == sFolderFullName
|
&& FolderUserStore.currentFolderFullName() == sFolderFullName
|
||||||
&& MessagelistUserStore.reload(true, true);
|
&& MessagelistUserStore.reload(true, true);
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,9 @@ export const
|
||||||
|| '';
|
|| '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getErrorMessage = (code, data) =>
|
||||||
|
getNotification(code) || data?.messageAdditional || data?.message || data,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} code
|
* @param {*} code
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ export const
|
||||||
// Repeat every 15 minutes?
|
// Repeat every 15 minutes?
|
||||||
// this.foldersTimeout = setTimeout(loadFolders, 900000);
|
// this.foldersTimeout = setTimeout(loadFolders, 900000);
|
||||||
})
|
})
|
||||||
.catch(() => fCallback && setTimeout(fCallback, 1, false));
|
.catch(e => fCallback && setTimeout(fCallback, 1, false, e));
|
||||||
};
|
};
|
||||||
|
|
||||||
export class FolderCollectionModel extends AbstractCollectionModel
|
export class FolderCollectionModel extends AbstractCollectionModel
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ let iJsonErrorCount = 0;
|
||||||
const getURL = (add = '') => serverRequest('Json') + pString(add),
|
const getURL = (add = '') => serverRequest('Json') + pString(add),
|
||||||
|
|
||||||
checkResponseError = data => {
|
checkResponseError = data => {
|
||||||
const err = data ? data.ErrorCode : null;
|
const err = data ? data.code : null;
|
||||||
if (Notifications.InvalidToken === err) {
|
if (Notifications.InvalidToken === err) {
|
||||||
console.error(getNotification(err) + ` (${data.ErrorMessageAdditional})`);
|
console.error(getNotification(err) + ` (${data.messageAdditional})`);
|
||||||
// alert(getNotification(err));
|
// alert(getNotification(err));
|
||||||
setTimeout(rl.logoutReload, 5000);
|
setTimeout(rl.logoutReload, 5000);
|
||||||
} else if ([
|
} else if ([
|
||||||
|
|
@ -144,7 +144,7 @@ export class AbstractFetchRemote
|
||||||
iJsonErrorCount = 0;
|
iJsonErrorCount = 0;
|
||||||
} else {
|
} else {
|
||||||
checkResponseError(data);
|
checkResponseError(data);
|
||||||
iError = data.ErrorCode || Notifications.UnknownError
|
iError = data.code || Notifications.UnknownError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ export class AbstractFetchRemote
|
||||||
return Promise.reject(new FetchError(Notifications.JsonParse));
|
return Promise.reject(new FetchError(Notifications.JsonParse));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (111 === data?.ErrorCode && rl.app.ask && await rl.app.ask.cryptkey()) {
|
if (111 === data?.code && rl.app.ask && await rl.app.ask.cryptkey()) {
|
||||||
return this.post(action, fTrigger, params, timeOut);
|
return this.post(action, fTrigger, params, timeOut);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -222,8 +222,8 @@ export class AbstractFetchRemote
|
||||||
if (!data.Result || action !== data.Action) {
|
if (!data.Result || action !== data.Action) {
|
||||||
checkResponseError(data);
|
checkResponseError(data);
|
||||||
return Promise.reject(new FetchError(
|
return Promise.reject(new FetchError(
|
||||||
data ? data.ErrorCode : 0,
|
data ? data.code : 0,
|
||||||
data ? (data.ErrorMessageAdditional || data.ErrorMessage) : ''
|
data ? (data.messageAdditional || data.message) : ''
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.packagesError(
|
this.packagesError(
|
||||||
getNotification(install ? Notifications.CantInstallPackage : Notifications.CantDeletePackage)
|
getNotification(install ? Notifications.CantInstallPackage : Notifications.CantDeletePackage)
|
||||||
+ (data.ErrorMessage ? ':\n' + data.ErrorMessage : '')
|
+ (data.message ? ':\n' + data.message : '')
|
||||||
);
|
);
|
||||||
} else if (data.Result.Reload) {
|
} else if (data.Result.Reload) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
@ -113,8 +113,8 @@ export class AdminSettingsPackages extends AbstractViewSettings {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
plugin.enabled(disable);
|
plugin.enabled(disable);
|
||||||
this.packagesError(
|
this.packagesError(
|
||||||
(Notifications.UnsupportedPluginPackage === iError && data?.ErrorMessage)
|
(Notifications.UnsupportedPluginPackage === iError && data?.message)
|
||||||
? data.ErrorMessage
|
? data.message
|
||||||
: getNotification(iError)
|
: getNotification(iError)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,8 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
||||||
themeBackground.hash(data?.Result?.hash || '');
|
themeBackground.hash(data?.Result?.hash || '');
|
||||||
if (!themeBackground.name() || !themeBackground.hash()) {
|
if (!themeBackground.name() || !themeBackground.hash()) {
|
||||||
let errorMsg = '';
|
let errorMsg = '';
|
||||||
if (data.ErrorCode) {
|
if (data.code) {
|
||||||
switch (data.ErrorCode) {
|
switch (data.code) {
|
||||||
case UploadErrorCode.FileIsTooBig:
|
case UploadErrorCode.FileIsTooBig:
|
||||||
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
|
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
|
||||||
break;
|
break;
|
||||||
|
|
@ -111,7 +111,7 @@ export class UserSettingsThemes /*extends AbstractViewSettings*/ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
themeBackground.error(errorMsg || data.ErrorMessage || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
|
themeBackground.error(errorMsg || data.message || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ export class SieveScriptPopupView extends rl.pluginPopupView {
|
||||||
|
|
||||||
if (iError) {
|
if (iError) {
|
||||||
self.saveError(true);
|
self.saveError(true);
|
||||||
self.errorText(data?.ErrorMessageAdditional || getNotification(iError));
|
self.errorText(data?.messageAdditional || getNotification(iError));
|
||||||
} else {
|
} else {
|
||||||
script.exists() || scripts.push(script);
|
script.exists() || scripts.push(script);
|
||||||
script.exists(true);
|
script.exists(true);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ ContactUserStore.sync = fResultFunc => {
|
||||||
line = JSON.parse(line);
|
line = JSON.parse(line);
|
||||||
if ('ContactsSync' === line.Action) {
|
if ('ContactsSync' === line.Action) {
|
||||||
ContactUserStore.syncing(false);
|
ContactUserStore.syncing(false);
|
||||||
fResultFunc?.(line.ErrorCode, line);
|
fResultFunc?.(line.code, line);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ContactUserStore.syncing(false);
|
ContactUserStore.syncing(false);
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export const GnuPGUserStore = new class {
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (oData) {
|
if (oData) {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
alert(oData.ErrorMessage);
|
alert(oData.message);
|
||||||
} else if (oData.Result) {
|
} else if (oData.Result) {
|
||||||
isPrivate
|
isPrivate
|
||||||
? this.privateKeys.remove(key)
|
? this.privateKeys.remove(key)
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export const
|
||||||
if (gnuPG && oData?.Result/* && (oData.Result.imported || oData.Result.secretimported)*/) {
|
if (gnuPG && oData?.Result/* && (oData.Result.imported || oData.Result.secretimported)*/) {
|
||||||
GnuPGUserStore.loadKeyrings();
|
GnuPGUserStore.loadKeyrings();
|
||||||
}
|
}
|
||||||
iError && alert(oData.ErrorMessage);
|
iError && alert(oData.message);
|
||||||
}, {
|
}, {
|
||||||
key, gnuPG, backup
|
key, gnuPG, backup
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ export class AccountPopupView extends AbstractViewPopup {
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.submitError(getNotification(iError));
|
this.submitError(getNotification(iError));
|
||||||
this.submitErrorAdditional(data?.ErrorMessageAdditional);
|
this.submitErrorAdditional(data?.messageAdditional);
|
||||||
} else {
|
} else {
|
||||||
loadAccountsAndIdentities();
|
loadAccountsAndIdentities();
|
||||||
this.close();
|
this.close();
|
||||||
|
|
|
||||||
|
|
@ -499,8 +499,8 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
const sendFailed = (iError, data) => {
|
const sendFailed = (iError, data) => {
|
||||||
this.sendError(true);
|
this.sendError(true);
|
||||||
this.sendErrorDesc(
|
this.sendErrorDesc(
|
||||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
getNotification(iError, data?.message, Notifications.CantSendMessage)
|
||||||
+ "\n" + (data?.ErrorMessageAdditional || data?.ErrorMessage)
|
+ "\n" + (data?.messageAdditional || data?.message)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
@ -530,8 +530,8 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
if (Notifications.CantSaveMessage === iError) {
|
if (Notifications.CantSaveMessage === iError) {
|
||||||
this.sendSuccessButSaveError(true);
|
this.sendSuccessButSaveError(true);
|
||||||
let msg = i18n('COMPOSE/SAVED_ERROR_ON_SEND');
|
let msg = i18n('COMPOSE/SAVED_ERROR_ON_SEND');
|
||||||
if (data?.ErrorMessageAdditional) {
|
if (data?.messageAdditional) {
|
||||||
msg = msg + "\n" + data?.ErrorMessageAdditional;
|
msg = msg + "\n" + data?.messageAdditional;
|
||||||
}
|
}
|
||||||
this.savedErrorDesc(msg);
|
this.savedErrorDesc(msg);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1151,7 +1151,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
.on('onComplete', (id, result, data) => {
|
.on('onComplete', (id, result, data) => {
|
||||||
const attachment = this.getAttachmentById(id),
|
const attachment = this.getAttachmentById(id),
|
||||||
response = data?.Result || {},
|
response = data?.Result || {},
|
||||||
errorCode = response.ErrorCode,
|
errorCode = response.code,
|
||||||
attachmentJson = result && response.Attachment;
|
attachmentJson = result && response.Attachment;
|
||||||
|
|
||||||
let error = '';
|
let error = '';
|
||||||
|
|
@ -1167,7 +1167,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
.waiting(false)
|
.waiting(false)
|
||||||
.uploading(false)
|
.uploading(false)
|
||||||
.complete(true)
|
.complete(true)
|
||||||
.error(error + '\n' + response.ErrorMessage);
|
.error(error + '\n' + response.message);
|
||||||
} else if (attachmentJson) {
|
} else if (attachmentJson) {
|
||||||
attachment
|
attachment
|
||||||
.waiting(false)
|
.waiting(false)
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export class ContactsPopupView extends AbstractViewPopup {
|
||||||
Remote.request('ContactsDelete',
|
Remote.request('ContactsDelete',
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
alert(oData?.ErrorMessage || getNotification(iError));
|
alert(oData?.message || getNotification(iError));
|
||||||
} else {
|
} else {
|
||||||
const page = this.contactsPage();
|
const page = this.contactsPage();
|
||||||
if (page > Math.max(1, Math.ceil((this.contactsCount() - count) / CONTACTS_PER_PAGE))) {
|
if (page > Math.max(1, Math.ceil((this.contactsCount() - count) / CONTACTS_PER_PAGE))) {
|
||||||
|
|
@ -181,7 +181,7 @@ export class ContactsPopupView extends AbstractViewPopup {
|
||||||
Remote.request('ContactSave',
|
Remote.request('ContactSave',
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
alert(oData?.ErrorMessage || getNotification(iError));
|
alert(oData?.message || getNotification(iError));
|
||||||
} else if (oData.Result.ResultID) {
|
} else if (oData.Result.ResultID) {
|
||||||
if (contact.id()) {
|
if (contact.id()) {
|
||||||
contact.id(oData.Result.ResultID);
|
contact.id(oData.Result.ResultID);
|
||||||
|
|
@ -245,7 +245,7 @@ export class ContactsPopupView extends AbstractViewPopup {
|
||||||
|
|
||||||
if (iError) {
|
if (iError) {
|
||||||
// console.error(data);
|
// console.error(data);
|
||||||
alert(data?.ErrorMessage || getNotification(iError));
|
alert(data?.message || getNotification(iError));
|
||||||
} else if (arrayLength(data.Result.List)) {
|
} else if (arrayLength(data.Result.List)) {
|
||||||
data.Result.List.forEach(item => {
|
data.Result.List.forEach(item => {
|
||||||
item = ContactModel.reviveFromJson(item);
|
item = ContactModel.reviveFromJson(item);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export class IdentityPopupView extends AbstractViewPopup {
|
||||||
identity.smimeKey(oData.Result.pkey);
|
identity.smimeKey(oData.Result.pkey);
|
||||||
identity.smimeCertificate(oData.Result.x509);
|
identity.smimeCertificate(oData.Result.x509);
|
||||||
} else {
|
} else {
|
||||||
this.submitError(oData.ErrorMessage);
|
this.submitError(oData.message);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: identity.name(),
|
name: identity.name(),
|
||||||
|
|
@ -81,7 +81,7 @@ export class IdentityPopupView extends AbstractViewPopup {
|
||||||
if (oData.Result) {
|
if (oData.Result) {
|
||||||
identity.smimeKey(oData.Result);
|
identity.smimeKey(oData.Result);
|
||||||
} else {
|
} else {
|
||||||
this.submitError(oData.ErrorMessage);
|
this.submitError(oData.message);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
privateKey: identity.smimeKey(),
|
privateKey: identity.smimeKey(),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
const fn = () => Remote.request('PgpSearchKey',
|
const fn = () => Remote.request('PgpSearchKey',
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.key(oData.ErrorMessage);
|
this.key(oData.message);
|
||||||
} else {
|
} else {
|
||||||
this.key(oData.Result);
|
this.key(oData.Result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ export class SMimeImportPopupView extends AbstractViewPopup {
|
||||||
(iError, oData) => {
|
(iError, oData) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
this.pemError(true);
|
this.pemError(true);
|
||||||
this.pemErrorMessage(getNotification(iError, oData?.ErrorMessage));
|
this.pemErrorMessage(getNotification(iError, oData?.message));
|
||||||
// oData?.ErrorMessageAdditional;
|
// oData?.messageAdditional;
|
||||||
} else {
|
} else {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,9 @@ export class LoginUserView extends AbstractViewLogin {
|
||||||
if (Notifications.InvalidInputArgument == iError) {
|
if (Notifications.InvalidInputArgument == iError) {
|
||||||
iError = Notifications.AuthError;
|
iError = Notifications.AuthError;
|
||||||
}
|
}
|
||||||
this.submitError(getNotification(iError, oData?.ErrorMessage,
|
this.submitError(getNotification(iError, oData?.message,
|
||||||
Notifications.UnknownError));
|
Notifications.UnknownError));
|
||||||
this.submitErrorAdditional(oData?.ErrorMessageAdditional || oData?.message);
|
this.submitErrorAdditional(oData?.messageAdditional || oData?.message);
|
||||||
} else {
|
} else {
|
||||||
rl.setData(oData.Result);
|
rl.setData(oData.Result);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
|
||||||
(iError/*, oData*/) => {
|
(iError/*, oData*/) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
AccountUserStore.loading(false);
|
AccountUserStore.loading(false);
|
||||||
alert(getNotification(iError).replace('%EMAIL%', email));
|
alert('Account error: ' + getNotification(iError).replace('%EMAIL%', email));
|
||||||
if (account.isAdditional()) {
|
if (account.isAdditional()) {
|
||||||
showScreenPopup(AccountPopupView, [account]);
|
showScreenPopup(AccountPopupView, [account]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,9 +123,9 @@ window.rl = {
|
||||||
return Promise.reject(Notifications.JsonParse);
|
return Promise.reject(Notifications.JsonParse);
|
||||||
return {
|
return {
|
||||||
Result: false,
|
Result: false,
|
||||||
ErrorCode: 952, // Notifications.JsonParse
|
code: 952, // Notifications.JsonParse
|
||||||
ErrorMessage: e.message,
|
message: e.message,
|
||||||
ErrorMessageAdditional: data
|
messageAdditional: data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ window.Sieve = {
|
||||||
Remote.request('FiltersScriptDelete',
|
Remote.request('FiltersScriptDelete',
|
||||||
(iError, data) =>
|
(iError, data) =>
|
||||||
iError
|
iError
|
||||||
? setError(data?.ErrorMessageAdditional || getNotification(iError))
|
? setError(data?.messageAdditional || getNotification(iError))
|
||||||
: scripts.remove(script)
|
: scripts.remove(script)
|
||||||
,
|
,
|
||||||
{name:script.name()}
|
{name:script.name()}
|
||||||
|
|
@ -69,7 +69,7 @@ window.Sieve = {
|
||||||
Remote.request('FiltersScriptActivate',
|
Remote.request('FiltersScriptActivate',
|
||||||
(iError, data) =>
|
(iError, data) =>
|
||||||
iError
|
iError
|
||||||
? setError(data?.ErrorMessageAdditional || iError)
|
? setError(data?.messageAdditional || iError)
|
||||||
: scripts.forEach(script => script.active(script.name() === name))
|
: scripts.forEach(script => script.active(script.name() === name))
|
||||||
,
|
,
|
||||||
{name:name}
|
{name:name}
|
||||||
|
|
|
||||||
|
|
@ -828,7 +828,7 @@ class Actions
|
||||||
$sError = Enumerations\UploadError::getUserMessage($iError, $iClientError);
|
$sError = Enumerations\UploadError::getUserMessage($iError, $iClientError);
|
||||||
|
|
||||||
if (!empty($sError)) {
|
if (!empty($sError)) {
|
||||||
$aResponse['ErrorCode'] = $iClientError;
|
$aResponse['code'] = $iClientError;
|
||||||
$aResponse['Error'] = $sError;
|
$aResponse['Error'] = $sError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ trait Response
|
||||||
public function DefaultResponse($mResult, array $aAdditionalParams = array(), string $sActionName = '') : array
|
public function DefaultResponse($mResult, array $aAdditionalParams = array(), string $sActionName = '') : array
|
||||||
{
|
{
|
||||||
if (false === $mResult) {
|
if (false === $mResult) {
|
||||||
if (!isset($aAdditionalParams['ErrorCode'])) {
|
if (!isset($aAdditionalParams['code'])) {
|
||||||
$aAdditionalParams['ErrorCode'] = 0;
|
$aAdditionalParams['code'] = 0;
|
||||||
}
|
}
|
||||||
if (!isset($aAdditionalParams['ErrorMessage'])) {
|
if (!isset($aAdditionalParams['message'])) {
|
||||||
$aAdditionalParams['ErrorMessage'] = '';
|
$aAdditionalParams['message'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,9 +36,9 @@ trait Response
|
||||||
public function FalseResponse(int $iErrorCode = 0, string $sErrorMessage = '', string $sAdditionalErrorMessage = '') : array
|
public function FalseResponse(int $iErrorCode = 0, string $sErrorMessage = '', string $sAdditionalErrorMessage = '') : array
|
||||||
{
|
{
|
||||||
return $this->DefaultResponse(false, [
|
return $this->DefaultResponse(false, [
|
||||||
'ErrorCode' => $iErrorCode,
|
'code' => $iErrorCode,
|
||||||
'ErrorMessage' => $sErrorMessage,
|
'message' => $sErrorMessage,
|
||||||
'ErrorMessageAdditional' => $sAdditionalErrorMessage
|
'messageAdditional' => $sAdditionalErrorMessage
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,9 +62,9 @@ trait Response
|
||||||
$this->logException($oException->getPrevious() ?: $oException);
|
$this->logException($oException->getPrevious() ?: $oException);
|
||||||
|
|
||||||
return $this->DefaultResponse(false, [
|
return $this->DefaultResponse(false, [
|
||||||
'ErrorCode' => $iErrorCode,
|
'code' => $iErrorCode,
|
||||||
'ErrorMessage' => $sErrorMessage,
|
'message' => $sErrorMessage,
|
||||||
'ErrorMessageAdditional' => $sErrorMessageAdditional,
|
'messageAdditional' => $sErrorMessageAdditional,
|
||||||
'ExceptionCode' => $iExceptionCode
|
'ExceptionCode' => $iExceptionCode
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,14 +94,20 @@ class ServiceActions
|
||||||
throw new Exceptions\ClientException(Notifications::InvalidInputArgument, null, 'Action unknown');
|
throw new Exceptions\ClientException(Notifications::InvalidInputArgument, null, 'Action unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = Utils::GetCsrfToken();
|
if ('Logout' !== $sAction) {
|
||||||
if (isset($_SERVER['HTTP_X_SM_TOKEN'])) {
|
$token = Utils::GetCsrfToken();
|
||||||
if ($_SERVER['HTTP_X_SM_TOKEN'] !== $token) {
|
if (isset($_SERVER['HTTP_X_SM_TOKEN'])) {
|
||||||
throw new Exceptions\ClientException(Notifications::InvalidToken, null, 'HTTP Token mismatch');
|
if ($_SERVER['HTTP_X_SM_TOKEN'] !== $token) {
|
||||||
}
|
$sEmail = $this->oActions->getAccountFromToken(false)->Email();
|
||||||
} else if ($this->oHttp->IsPost()) {
|
$this->oActions->logWrite("{$_SERVER['HTTP_X_SM_TOKEN']} !== {$token} for {$sEmail}", \LOG_ERROR, 'Token');
|
||||||
if (empty($_POST['XToken']) || $_POST['XToken'] !== $token) {
|
throw new Exceptions\ClientException(Notifications::InvalidToken, null, 'HTTP Token mismatch');
|
||||||
throw new Exceptions\ClientException(Notifications::InvalidToken, null, 'XToken Token mismatch');
|
}
|
||||||
|
} else if ($this->oHttp->IsPost()) {
|
||||||
|
if (empty($_POST['XToken']) || $_POST['XToken'] !== $token) {
|
||||||
|
$sEmail = $this->oActions->getAccountFromToken(false)->Email();
|
||||||
|
$this->oActions->logWrite("{$_POST['XToken']} !== {$token} for {$sEmail}", \LOG_ERROR, 'XToken');
|
||||||
|
throw new Exceptions\ClientException(Notifications::InvalidToken, null, 'XToken mismatch');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,11 @@ class Utils
|
||||||
{
|
{
|
||||||
$oActions = \RainLoop\Api::Actions();
|
$oActions = \RainLoop\Api::Actions();
|
||||||
$oAccount = $oActions->getAccountFromToken(false);
|
$oAccount = $oActions->getAccountFromToken(false);
|
||||||
|
// $oAccount = $oActions->getMainAccountFromToken(false);
|
||||||
if ($oAccount) {
|
if ($oAccount) {
|
||||||
return '2-' . \sha1(APP_SALT.$oAccount->Hash());
|
if ($oAccount instanceof \RainLoop\Model\AdditionalAccount) {
|
||||||
}
|
return '2-' . \sha1(APP_SALT.$oAccount->Hash());
|
||||||
$oAccount = $oActions->getMainAccountFromToken(false);
|
}
|
||||||
if ($oAccount) {
|
|
||||||
return '1-' . \sha1(APP_SALT.$oAccount->Hash());
|
return '1-' . \sha1(APP_SALT.$oAccount->Hash());
|
||||||
}
|
}
|
||||||
$sToken = \SnappyMail\Cookies::get(self::CONNECTION_TOKEN);
|
$sToken = \SnappyMail\Cookies::get(self::CONNECTION_TOKEN);
|
||||||
|
|
@ -82,7 +82,7 @@ class Utils
|
||||||
$sToken = \MailSo\Base\Utils::Sha1Rand(APP_SALT);
|
$sToken = \MailSo\Base\Utils::Sha1Rand(APP_SALT);
|
||||||
\SnappyMail\Cookies::set(self::CONNECTION_TOKEN, $sToken, \time() + 3600 * 24 * 30);
|
\SnappyMail\Cookies::set(self::CONNECTION_TOKEN, $sToken, \time() + 3600 * 24 * 30);
|
||||||
}
|
}
|
||||||
return \sha1('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
|
return '0-' . \sha1('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetCsrfToken() : string
|
public static function GetCsrfToken() : string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue