mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
WebClient: improve error message after the session expires
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -273,7 +273,8 @@
|
||||
"thursday": "Thursday",
|
||||
"friday": "Friday",
|
||||
"saturday": "Saturday",
|
||||
"sunday": "Sunday"
|
||||
"sunday": "Sunday",
|
||||
"expired_session": "Your session has expired. Please log in again"
|
||||
},
|
||||
"fs": {
|
||||
"view_file": "View file \"{{- path}}\"",
|
||||
|
||||
@@ -273,7 +273,8 @@
|
||||
"thursday": "Giovedì",
|
||||
"friday": "Venerdì",
|
||||
"saturday": "Sabato",
|
||||
"sunday": "Domenica"
|
||||
"sunday": "Domenica",
|
||||
"expired_session": "La tua sessione è scaduta. Effettua nuovamente l'accesso"
|
||||
},
|
||||
"fs": {
|
||||
"view_file": "Visualizza file \"{{- path}}\"",
|
||||
|
||||
@@ -349,6 +349,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
if (json.message) {
|
||||
txt = json.message;
|
||||
}
|
||||
} else {
|
||||
txt = "general.expired_session";
|
||||
}
|
||||
}
|
||||
if (!txt){
|
||||
@@ -500,6 +502,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
let errorMessage = "";
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 200:
|
||||
errorMessage = "general.expired_session";
|
||||
case 403:
|
||||
errorMessage = "fs.create_dir.err_403";
|
||||
break;
|
||||
@@ -1477,8 +1481,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
}).then((result)=>{
|
||||
if (result.error) {
|
||||
hasError = true;
|
||||
let message = "fs.copy.err_generic";
|
||||
if (result.is_redirect){
|
||||
message = "general.expired_session";
|
||||
}
|
||||
ModalAlert.fire({
|
||||
text: $.t("fs.copy.err_generic"),
|
||||
text: $.t(message),
|
||||
icon: "warning",
|
||||
confirmButtonText: $.t('general.ok'),
|
||||
customClass: {
|
||||
@@ -1626,8 +1634,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
}).then((result)=>{
|
||||
if (result.error) {
|
||||
hasError = true;
|
||||
let message = "fs.move.err_generic";
|
||||
if (result.is_redirect){
|
||||
message = "general.expired_session";
|
||||
}
|
||||
ModalAlert.fire({
|
||||
text: $.t("fs.move.err_generic"),
|
||||
text: $.t(message),
|
||||
icon: "warning",
|
||||
confirmButtonText: $.t('general.ok'),
|
||||
customClass: {
|
||||
@@ -1653,6 +1665,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
KTApp.hidePageLoading();
|
||||
let errorMessage;
|
||||
switch (status) {
|
||||
case 405:
|
||||
errorMessage = "general.expired_session";
|
||||
break;
|
||||
case 403:
|
||||
errorMessage = "fs.delete.err_403";
|
||||
break;
|
||||
@@ -1860,8 +1875,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
}).then((result)=>{
|
||||
if (result.error) {
|
||||
KTApp.hidePageLoading();
|
||||
let message = $.t('fs.rename.err_generic', { name: oldName });
|
||||
if (result.is_redirect){
|
||||
message = $.t('general.expired_session');
|
||||
}
|
||||
ModalAlert.fire({
|
||||
text: $.t('fs.rename.err_generic', { name: oldName }),
|
||||
text: message,
|
||||
icon: "warning",
|
||||
confirmButtonText: $.t('general.ok'),
|
||||
customClass: {
|
||||
@@ -1951,6 +1970,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
let errorMessage = "";
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 200:
|
||||
errorMessage = "general.expired_session";
|
||||
case 403:
|
||||
errorMessage = "fs.create_dir.err_403";
|
||||
break;
|
||||
@@ -2100,7 +2121,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
}).then((result)=> {
|
||||
if (result.error) {
|
||||
has_errors = true;
|
||||
setI18NData($('#errorTxt'), "fs.upload.err_generic");
|
||||
let message = "fs.upload.err_generic";
|
||||
if (result.is_redirect){
|
||||
message = "general.expired_session";
|
||||
}
|
||||
setI18NData($('#errorTxt'), message);
|
||||
$('#errorMsg').removeClass("d-none");
|
||||
uploadFile();
|
||||
return;
|
||||
@@ -2163,13 +2188,16 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
||||
return status == 200;
|
||||
}
|
||||
}).then(function(response){
|
||||
let isJsonResponse = response.headers['content-type'] === 'application/json'
|
||||
promiseResolve({
|
||||
error: false,
|
||||
error: !isJsonResponse,
|
||||
is_redirect: !isJsonResponse,
|
||||
data: response.data
|
||||
});
|
||||
}).catch(function(error){
|
||||
promiseResolve({
|
||||
error: true
|
||||
error: true,
|
||||
is_redirect: false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user